Fix the spam on disconnect

This commit is contained in:
Capucho 2020-03-08 08:54:29 +00:00
parent 9d805a745e
commit 5fe9521233
3 changed files with 2 additions and 13 deletions

View File

@ -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.

View File

@ -16,7 +16,6 @@ pub enum ClientState {
Registered,
Spectator,
Character,
Disconnected,
}
pub const MAX_BYTES_CHAT_MSG: usize = 256;

View File

@ -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),