From 7d0941dee83d9d54b73dd9cacc61a259e5169152 Mon Sep 17 00:00:00 2001 From: Luuk van Oijen Date: Mon, 20 Nov 2023 12:53:37 +0100 Subject: [PATCH] now it updates whenever new data is ready --- src/heartbeat.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/heartbeat.rs b/src/heartbeat.rs index ee3c917..f8cfbd4 100644 --- a/src/heartbeat.rs +++ b/src/heartbeat.rs @@ -41,12 +41,15 @@ pub async fn backend_heartbeat(config: std::sync::Arc, mu loop { interval.tick().await; - heartbeat_post(&info).await; - - if let Ok(status) = hb_rx.try_recv() { - trace!("status update: {:?}", status); - info.players = status.player_count; - info.playerslist = status.player_list.clone(); + tokio::select! { + _ = heartbeat_post(&info) => {} + status = hb_rx.recv() => { + if let Some(status) = status { + trace!("status update: {:?}", status); + info.players = status.player_count; + info.playerslist = status.player_list.clone(); + } + } } } }