fix reconnecting with same peer ID

pull/19/head
Niko PLP 4 months ago
parent 46c15a4a2b
commit 2c99417edf
  1. 13
      ng-net/src/broker.rs
  2. 2
      ng-net/src/connection.rs

@ -396,9 +396,10 @@ impl Broker {
match removed { match removed {
Some(info) => match info.connected { Some(info) => match info.connected {
PeerConnection::NONE => {} PeerConnection::NONE => {}
PeerConnection::Client(_cb) => { PeerConnection::Client(mut _cb) => {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
if user.is_none() { if user.is_none() {
_cb.release_shutdown();
// server side // server side
if let Some(fsm) = _cb.fsm { if let Some(fsm) = _cb.fsm {
if let Ok(user) = fsm.lock().await.user_id() { if let Ok(user) = fsm.lock().await.user_id() {
@ -638,8 +639,14 @@ impl Broker {
let res = join.next().await; let res = join.next().await;
match res { match res {
Some(Either::Right(remote_peer_id)) => { Some(Either::Right(remote_peer_id)) => {
let _res = join.next().await; let res = join.next().await;
log_debug!("SOCKET IS CLOSED {:?} peer_id: {:?}", _res, remote_peer_id);
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 BROKER
.write() .write()
.await .await

@ -1138,7 +1138,7 @@ impl ConnectionBase {
pub async fn reset_shutdown(&mut self, remote_peer_id: X25519PrivKey) { pub async fn reset_shutdown(&mut self, remote_peer_id: X25519PrivKey) {
let _ = self let _ = self
.shutdown_sender .shutdown_sender
.take() .as_ref()
.unwrap() .unwrap()
.send(Either::Right(remote_peer_id)) .send(Either::Right(remote_peer_id))
.await; .await;

Loading…
Cancel
Save