From c1f1ec028fc8b0be561f893ef4dbbd80c4124d43 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sat, 4 Feb 2023 22:20:19 +0100 Subject: [PATCH] add kick reason --- kubi-udp/src/client.rs | 5 +++-- kubi-udp/src/common.rs | 2 +- kubi-udp/src/packet.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kubi-udp/src/client.rs b/kubi-udp/src/client.rs index 4bddda6..55d0917 100644 --- a/kubi-udp/src/client.rs +++ b/kubi-udp/src/client.rs @@ -139,9 +139,10 @@ impl Client 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) => { diff --git a/kubi-udp/src/common.rs b/kubi-udp/src/common.rs index ec4b097..83a40ef 100644 --- a/kubi-udp/src/common.rs +++ b/kubi-udp/src/common.rs @@ -9,7 +9,7 @@ pub enum DisconnectReason { #[default] NotConnected, ClientDisconnected, - KickedByServer, + KickedByServer(String), ClientTimeout, ServerTimeout, } diff --git a/kubi-udp/src/packet.rs b/kubi-udp/src/packet.rs index d824d2c..8f13403 100644 --- a/kubi-udp/src/packet.rs +++ b/kubi-udp/src/packet.rs @@ -18,7 +18,7 @@ pub struct IdClientPacket(pub Option, pub ClientPa pub enum ServerPacket where T: Encode + Decode { Data(T), Connected(ClientId), - Disconnected, + Disconnected(String), } #[derive(Encode, Decode)]