mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix the spam on disconnect
This commit is contained in:
@ -199,10 +199,7 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send disconnect message to the server
|
/// Send disconnect message to the server
|
||||||
pub fn request_logout(&mut self) {
|
pub fn request_logout(&mut self) { self.postbox.send_message(ClientMsg::Disconnect); }
|
||||||
self.postbox.send_message(ClientMsg::Disconnect);
|
|
||||||
self.client_state = ClientState::Disconnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Request a state transition to `ClientState::Registered` from an ingame
|
/// Request a state transition to `ClientState::Registered` from an ingame
|
||||||
/// state.
|
/// state.
|
||||||
|
@ -16,7 +16,6 @@ pub enum ClientState {
|
|||||||
Registered,
|
Registered,
|
||||||
Spectator,
|
Spectator,
|
||||||
Character,
|
Character,
|
||||||
Disconnected,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const MAX_BYTES_CHAT_MSG: usize = 256;
|
pub const MAX_BYTES_CHAT_MSG: usize = 256;
|
||||||
|
@ -91,7 +91,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|| client.postbox.error().is_some()
|
|| client.postbox.error().is_some()
|
||||||
// Postbox error
|
// Postbox error
|
||||||
{
|
{
|
||||||
disconnect = true;
|
server_emitter.emit(ServerEvent::ClientDisconnect(entity));
|
||||||
} else if time - client.last_ping > CLIENT_TIMEOUT * 0.5 {
|
} else if time - client.last_ping > CLIENT_TIMEOUT * 0.5 {
|
||||||
// Try pinging the client if the timeout is nearing.
|
// Try pinging the client if the timeout is nearing.
|
||||||
client.postbox.send_message(ServerMsg::Ping);
|
client.postbox.send_message(ServerMsg::Ping);
|
||||||
@ -111,7 +111,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
server_emitter.emit(ServerEvent::ExitIngame { entity });
|
server_emitter.emit(ServerEvent::ExitIngame { entity });
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
// Request spectator state
|
// Request spectator state
|
||||||
ClientMsg::Spectate => match client.client_state {
|
ClientMsg::Spectate => match client.client_state {
|
||||||
@ -122,7 +121,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
client.allow_state(ClientState::Spectator)
|
client.allow_state(ClientState::Spectator)
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
// Valid player
|
// Valid player
|
||||||
ClientMsg::Register { player, password } if player.is_valid() => {
|
ClientMsg::Register { player, password } if player.is_valid() => {
|
||||||
@ -189,7 +187,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
},
|
},
|
||||||
ClientState::Character => client.error_state(RequestStateError::Already),
|
ClientState::Character => client.error_state(RequestStateError::Already),
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
ClientMsg::ControllerInputs(inputs) => match client.client_state {
|
ClientMsg::ControllerInputs(inputs) => match client.client_state {
|
||||||
ClientState::Connected
|
ClientState::Connected
|
||||||
@ -203,7 +200,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
ClientMsg::ControlEvent(event) => match client.client_state {
|
ClientMsg::ControlEvent(event) => match client.client_state {
|
||||||
ClientState::Connected
|
ClientState::Connected
|
||||||
@ -217,7 +213,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
ClientMsg::ChatMsg { message } => match client.client_state {
|
ClientMsg::ChatMsg { message } => match client.client_state {
|
||||||
ClientState::Connected => client.error_state(RequestStateError::Impossible),
|
ClientState::Connected => client.error_state(RequestStateError::Impossible),
|
||||||
@ -232,7 +227,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state {
|
ClientMsg::PlayerPhysics { pos, vel, ori } => match client.client_state {
|
||||||
ClientState::Character => {
|
ClientState::Character => {
|
||||||
@ -273,7 +267,6 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ClientState::Pending => {},
|
ClientState::Pending => {},
|
||||||
ClientState::Disconnected => unreachable!(),
|
|
||||||
},
|
},
|
||||||
// Always possible.
|
// Always possible.
|
||||||
ClientMsg::Ping => client.postbox.send_message(ServerMsg::Pong),
|
ClientMsg::Ping => client.postbox.send_message(ServerMsg::Pong),
|
||||||
|
Reference in New Issue
Block a user