diff --git a/client/src/lib.rs b/client/src/lib.rs index 14bbb8d96f..a1d8e89480 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -224,10 +224,7 @@ impl Client { } /// Send disconnect message to the server - pub fn request_logout(&mut self) { - self.postbox.send_message(ClientMsg::Disconnect); - self.client_state = ClientState::Disconnected; - } + pub fn request_logout(&mut self) { self.postbox.send_message(ClientMsg::Disconnect); } /// Request a state transition to `ClientState::Registered` from an ingame /// state. diff --git a/common/src/msg/mod.rs b/common/src/msg/mod.rs index ad9e8411f0..1c04fece94 100644 --- a/common/src/msg/mod.rs +++ b/common/src/msg/mod.rs @@ -16,7 +16,6 @@ pub enum ClientState { Registered, Spectator, Character, - Disconnected, } pub const MAX_BYTES_CHAT_MSG: usize = 256; diff --git a/server/src/sys/message.rs b/server/src/sys/message.rs index 5ee72f410e..0274184af6 100644 --- a/server/src/sys/message.rs +++ b/server/src/sys/message.rs @@ -91,7 +91,7 @@ impl<'a> System<'a> for Sys { || client.postbox.error().is_some() // Postbox error { - disconnect = true; + server_emitter.emit(ServerEvent::ClientDisconnect(entity)); } else if time - client.last_ping > CLIENT_TIMEOUT * 0.5 { // Try pinging the client if the timeout is nearing. client.postbox.send_message(ServerMsg::Ping); @@ -111,7 +111,6 @@ impl<'a> System<'a> for Sys { server_emitter.emit(ServerEvent::ExitIngame { entity }); }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, // Request spectator state ClientMsg::Spectate => match client.client_state { @@ -122,7 +121,6 @@ impl<'a> System<'a> for Sys { client.allow_state(ClientState::Spectator) }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, // Request registered state (login) ClientMsg::Register { @@ -202,7 +200,6 @@ impl<'a> System<'a> for Sys { }, ClientState::Character => client.error_state(RequestStateError::Already), ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, ClientMsg::ControllerInputs(inputs) => match client.client_state { ClientState::Connected @@ -216,7 +213,6 @@ impl<'a> System<'a> for Sys { } }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, ClientMsg::ControlEvent(event) => match client.client_state { ClientState::Connected @@ -230,7 +226,6 @@ impl<'a> System<'a> for Sys { } }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, ClientMsg::ChatMsg { message } => match client.client_state { ClientState::Connected => client.error_state(RequestStateError::Impossible), @@ -245,7 +240,6 @@ impl<'a> System<'a> for Sys { ), }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state { ClientState::Character => { @@ -286,7 +280,6 @@ impl<'a> System<'a> for Sys { } }, ClientState::Pending => {}, - ClientState::Disconnected => unreachable!(), }, // Always possible. ClientMsg::Ping => client.postbox.send_message(ServerMsg::Pong),