1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-19 22:36:49 +00:00

Remove disconnected clients from the client list

This commit is contained in:
Joshua Goins 2025-04-01 22:24:58 -04:00
parent 121415b163
commit df1d0b2629
2 changed files with 6 additions and 0 deletions

View file

@ -122,6 +122,9 @@ async fn main_loop(mut recv: Receiver<ToServer>) -> Result<(), std::io::Error> {
}
}
}
ToServer::Disconnected(from_id) => {
to_remove.push(from_id);
}
ToServer::FatalError(err) => return Err(err),
}
}
@ -573,6 +576,8 @@ async fn client_loop(
}
ClientZoneIpcData::Disconnected { .. } => {
tracing::info!("Client disconnected!");
connection.handle.send(ToServer::Disconnected(connection.id)).await;
}
ClientZoneIpcData::ChatMessage(chat_message) => {
connection.handle.send(ToServer::Message(connection.id, chat_message.message.clone())).await;

View file

@ -99,6 +99,7 @@ pub enum ToServer {
ActorSpawned(ClientId, Actor, CommonSpawn),
ActorMoved(ClientId, u32, Position, f32),
ZoneLoaded(ClientId),
Disconnected(ClientId),
FatalError(std::io::Error),
}