aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2023-03-22 21:46:12 +0100
committerGitHub <noreply@github.com>2023-03-22 20:46:12 +0000
commit5e096f84e59eae0ed6b7bb758149c491c87538a6 (patch)
tree521db07bc7f1cd1420e6a9687b3bc9ee21ce328b /src-tauri/src/main.rs
parent423775e903dfe630ad9af2f1dacdd1a1729023ae (diff)
downloadFlightCore-5e096f84e59eae0ed6b7bb758149c491c87538a6.tar.gz
FlightCore-5e096f84e59eae0ed6b7bb758149c491c87538a6.zip
feat: Refresh statistics (#228)
* feat: fetch stats every 5 minutes and ping front with received information * feat: update front on stats reception * style: format code * fix: Add comment --------- Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index d2f7951d..d5fef9cb 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -10,7 +10,7 @@ use std::{
};
use app::{
- constants::{APP_USER_AGENT, MASTER_SERVER_URL, SERVER_BROWSER_ENDPOINT},
+ constants::{APP_USER_AGENT, MASTER_SERVER_URL, REFRESH_DELAY, SERVER_BROWSER_ENDPOINT},
*,
};
@@ -96,6 +96,17 @@ fn main() {
}
});
+ // Emit updated player and server count to GUI
+ let app_handle = app.app_handle();
+ tauri::async_runtime::spawn(async move {
+ loop {
+ sleep(REFRESH_DELAY).await;
+ app_handle
+ .emit_all("northstar-statistics", get_server_player_count().await)
+ .unwrap();
+ }
+ });
+
Ok(())
})
.manage(Counter(Default::default()))