Skip to content

Commit

Permalink
Delay mdns shutdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxxu committed Nov 5, 2024
1 parent 122e944 commit 6f3d393
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions crates/client/src/lan/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
}
Expand All @@ -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;
}

Expand All @@ -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
Expand Down

0 comments on commit 6f3d393

Please sign in to comment.