diff --git a/ng-net/src/broker.rs b/ng-net/src/broker.rs index 6a3e2d9..4b9ca15 100644 --- a/ng-net/src/broker.rs +++ b/ng-net/src/broker.rs @@ -396,9 +396,10 @@ impl Broker { match removed { Some(info) => match info.connected { PeerConnection::NONE => {} - PeerConnection::Client(_cb) => { + PeerConnection::Client(mut _cb) => { #[cfg(not(target_arch = "wasm32"))] if user.is_none() { + _cb.release_shutdown(); // server side if let Some(fsm) = _cb.fsm { if let Ok(user) = fsm.lock().await.user_id() { @@ -638,8 +639,14 @@ impl Broker { let res = join.next().await; match res { Some(Either::Right(remote_peer_id)) => { - let _res = join.next().await; - log_debug!("SOCKET IS CLOSED {:?} peer_id: {:?}", _res, remote_peer_id); + let res = join.next().await; + + if res.is_some() + && res.as_ref().unwrap().as_ref().unwrap_left() == &NetError::Closing + { + return; + } + log_debug!("SOCKET IS CLOSED {:?} peer_id: {:?}", res, remote_peer_id); BROKER .write() .await diff --git a/ng-net/src/connection.rs b/ng-net/src/connection.rs index 820fb00..b78a5b3 100644 --- a/ng-net/src/connection.rs +++ b/ng-net/src/connection.rs @@ -1138,7 +1138,7 @@ impl ConnectionBase { pub async fn reset_shutdown(&mut self, remote_peer_id: X25519PrivKey) { let _ = self .shutdown_sender - .take() + .as_ref() .unwrap() .send(Either::Right(remote_peer_id)) .await;