From 6f3d393b4f82304213f474c6c811c004af8b190d Mon Sep 17 00:00:00 2001 From: Flux Xu Date: Tue, 5 Nov 2024 15:44:19 -0500 Subject: [PATCH] Delay mdns shutdown. --- crates/client/src/lan/game/mod.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/crates/client/src/lan/game/mod.rs b/crates/client/src/lan/game/mod.rs index 2e16c9c..71689c1 100644 --- a/crates/client/src/lan/game/mod.rs +++ b/crates/client/src/lan/game/mod.rs @@ -15,8 +15,8 @@ use crate::node::NodeInfo; use flo_lan::{GameInfo, MdnsPublisher}; use flo_state::Addr; use flo_task::SpawnScope; -use flo_types::node::{NodeGameStatus, SlotClientStatus}; use flo_types::game::LocalGameInfo; +use flo_types::node::{NodeGameStatus, SlotClientStatus}; use flo_w3gs::protocol::game::GameSettings; use flo_w3map::MapChecksum; use proxy::LanProxy; @@ -73,7 +73,7 @@ impl LanGame { my_player_id, game.random_seed, &game.slots, - game.map_twelve_p + game.map_twelve_p, )?, game, map_checksum, @@ -106,7 +106,7 @@ impl LanGame { _ = mdns_shutdown_notify.notified() => {} } - sleep(Duration::from_secs(1)).await; + // sleep(Duration::from_secs(1)).await; tracing::debug!("exiting") } @@ -127,15 +127,6 @@ impl LanGame { } pub async fn update_game_status(&self, status: NodeGameStatus) { - if ![ - NodeGameStatus::Created, - NodeGameStatus::Waiting, - NodeGameStatus::Loading, - ] - .contains(&status) - { - self.mdns_shutdown_notify.notify_one(); - } self.proxy.dispatch_game_status_change(status).await; } @@ -151,6 +142,7 @@ impl LanGame { } pub fn shutdown(self) { + self.mdns_shutdown_notify.notify_one(); tokio::spawn(async move { if let Err(_) = tokio::time::timeout(std::time::Duration::from_secs(10), self.proxy.shutdown()).await