now it updates whenever new data is ready

This commit is contained in:
Luuk van Oijen committed 2023-11-20 12:53:37 +01:00
1 parent 0e75a35c83
commit 7d0941dee8
1 file changed
+6 -3
+6 -3
View File
@@ -41,15 +41,18 @@ pub async fn backend_heartbeat(config: std::sync::Arc<crate::config::Config>, mu
loop { loop {
interval.tick().await; interval.tick().await;
heartbeat_post(&info).await; tokio::select! {
_ = heartbeat_post(&info) => {}
if let Ok(status) = hb_rx.try_recv() { status = hb_rx.recv() => {
if let Some(status) = status {
trace!("status update: {:?}", status); trace!("status update: {:?}", status);
info.players = status.player_count; info.players = status.player_count;
info.playerslist = status.player_list.clone(); info.playerslist = status.player_list.clone();
} }
} }
} }
}
}
async fn heartbeat_post(heartbeat_info: &HeartbeatInfo) { async fn heartbeat_post(heartbeat_info: &HeartbeatInfo) {
match reqwest::Client::builder() match reqwest::Client::builder()