From df1d0b26297a58ce70cebb459808580591826d1a Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 1 Apr 2025 22:24:58 -0400 Subject: [PATCH] Remove disconnected clients from the client list --- src/bin/kawari-world.rs | 5 +++++ src/world/connection.rs | 1 + 2 files changed, 6 insertions(+) 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), }