don't hydrate client if user is disconnected

This commit is contained in:
Adam 2024-11-21 13:04:24 -05:00
parent 53b6d63f3d
commit d0ac4bb93b

View file

@ -177,14 +177,26 @@ impl UserHandler {
.insert(addr, new_user.clone());
// Hydrate client
let tx = self.state.tx_game_handler.clone();
let msg = GameHandlerMessage::BroadcastGamesUpdate();
tokio::spawn(async move { tx.send(msg).await });
let msg = GameHandlerMessage::SendCardPacks(dm_tx.clone());
if let Err(e) = self.state.tx_game_handler.send(msg).await {
if !dm_tx.is_closed() {
if let Err(e) = self
.state
.tx_game_handler
.send(GameHandlerMessage::BroadcastGamesUpdate())
.await
{
tracing::error!("Error contacing game handler {}", e)
}
if let Err(e) = self
.state
.tx_game_handler
.send(GameHandlerMessage::SendCardPacks(dm_tx.clone()))
.await
{
tracing::error!("Error contacing game handler {}", e)
}
}
// Broadcast new user's existence
// TODO: this should probably be combined and sent as one
let tx = self.state.tx_broadcast.clone();