add kick reason

This commit is contained in:
griffi-gh 2023-02-04 22:20:19 +01:00
parent da8ca65a3d
commit bbfde7f0eb
3 changed files with 5 additions and 4 deletions

View file

@ -139,9 +139,10 @@ impl<S, R> Client<S, R> where S: Encode + Decode, R: Encode + Decode {
self.status = ClientStatus::Connected;
return Ok(())
},
ServerPacket::Disconnected => {
ServerPacket::Disconnected(reason) => {
//this should never fail but we're handling the error anyway
self.disconnect_inner(DisconnectReason::KickedByServer, true)?;
let reason = DisconnectReason::KickedByServer(reason);
self.disconnect_inner(reason, true)?;
return Ok(())
},
ServerPacket::Data(message) => {

View file

@ -9,7 +9,7 @@ pub enum DisconnectReason {
#[default]
NotConnected,
ClientDisconnected,
KickedByServer,
KickedByServer(String),
ClientTimeout,
ServerTimeout,
}

View file

@ -18,7 +18,7 @@ pub struct IdClientPacket<T: Encode + Decode>(pub Option<ClientId>, pub ClientPa
pub enum ServerPacket<T> where T: Encode + Decode {
Data(T),
Connected(ClientId),
Disconnected,
Disconnected(String),
}
#[derive(Encode, Decode)]