diff --git a/kubi-udp/src/client.rs b/kubi-udp/src/client.rs index 7667e16..be9d6e1 100644 --- a/kubi-udp/src/client.rs +++ b/kubi-udp/src/client.rs @@ -21,6 +21,7 @@ pub enum DisconnectReason { ClientDisconnected, KickedByServer(Option), Timeout, + ConnectionReset, } #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -213,7 +214,16 @@ impl Client where S: Encode + Decode, R: Encode + Decode { } }, Err(error) if error.kind() != ErrorKind::WouldBlock => { - return Err(error.into()); + match error.kind() { + ErrorKind::ConnectionReset => { + log::error!("Connection interrupted"); + self.disconnect_inner(DisconnectReason::ConnectionReset, true)?; + }, + _ => { + log::error!("IO error {error}"); + return Err(error.into()); + }, + } }, _ => break, } diff --git a/kubi-udp/src/server.rs b/kubi-udp/src/server.rs index 05cd01e..b15a185 100644 --- a/kubi-udp/src/server.rs +++ b/kubi-udp/src/server.rs @@ -189,7 +189,7 @@ impl Server where S: Encode + Decode, R: Encode + Decode { } }, Err(error) if error.kind() != ErrorKind::WouldBlock => { - log::warn!("IO error {}", error); + log::error!("IO error {}", error); // return Err(error.into()); }, _ => break, diff --git a/kubi/src/networking.rs b/kubi/src/networking.rs index 65fd538..16450b0 100644 --- a/kubi/src/networking.rs +++ b/kubi/src/networking.rs @@ -26,6 +26,7 @@ pub struct NetworkEvent(pub ClientEvent); pub fn create_client( storages: AllStoragesView ) { + log::info!("Creating client"); let address = storages.borrow::>().unwrap(); storages.add_unique(UdpClient(Client::new( address.0, @@ -37,7 +38,8 @@ pub fn create_client( pub fn connect_client( mut client: UniqueViewMut ) { - if !client.0.has_not_made_connection_attempts() { + if client.0.has_not_made_connection_attempts() { + log::info!("Connect called"); client.0.connect().unwrap(); } }