diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index a847685..dc8aefe 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -122,6 +122,9 @@ async fn main_loop(mut recv: Receiver) -> 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; diff --git a/src/world/connection.rs b/src/world/connection.rs index f3fe69e..cbfdf5b 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -99,6 +99,7 @@ pub enum ToServer { ActorSpawned(ClientId, Actor, CommonSpawn), ActorMoved(ClientId, u32, Position, f32), ZoneLoaded(ClientId), + Disconnected(ClientId), FatalError(std::io::Error), }