From 529e854a5ecbc99f0d9e41cde59983e14cc1a854 Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Sun, 22 Sep 2024 12:43:12 +0800 Subject: [PATCH 1/2] fix: Handle disconnect reasons correctly. --- lib/src/core/engine.dart | 13 ++++++++++++- lib/src/core/room.dart | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index d46acc0f..d0b4178c 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -1037,7 +1037,18 @@ class Engine extends Disposable with EventsEmittable { return; } await signalClient.cleanUp(); - await cleanUp(); + if ([ + DisconnectReason.duplicateIdentity, + DisconnectReason.participantRemoved, + DisconnectReason.roomDeleted, + DisconnectReason.stateMismatch, + DisconnectReason.serverShutdown, + ].contains(event.reason.toSDKType())) { + fullReconnectOnNext = false; + await disconnect(); + } else { + await cleanUp(); + } events .emit(EngineDisconnectedEvent(reason: event.reason.toSDKType())); break; diff --git a/lib/src/core/room.dart b/lib/src/core/room.dart index ab44cc8a..4426e2bf 100644 --- a/lib/src/core/room.dart +++ b/lib/src/core/room.dart @@ -519,9 +519,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable { }) ..on((event) async { if (!engine.fullReconnectOnNext && - ![ + [ DisconnectReason.signalingConnectionFailure, DisconnectReason.joinFailure, + DisconnectReason.duplicateIdentity, + DisconnectReason.participantRemoved, + DisconnectReason.roomDeleted, + DisconnectReason.stateMismatch, + DisconnectReason.serverShutdown, DisconnectReason.noInternetConnection ].contains(event.reason)) { await _cleanUp(); From 29453ac9bd61ee36582819250153ab6513dcfeaf Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Sun, 22 Sep 2024 13:08:31 +0800 Subject: [PATCH 2/2] update. --- lib/src/core/engine.dart | 14 ++------------ lib/src/core/room.dart | 12 +----------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/src/core/engine.dart b/lib/src/core/engine.dart index d0b4178c..42d1db76 100644 --- a/lib/src/core/engine.dart +++ b/lib/src/core/engine.dart @@ -1037,18 +1037,8 @@ class Engine extends Disposable with EventsEmittable { return; } await signalClient.cleanUp(); - if ([ - DisconnectReason.duplicateIdentity, - DisconnectReason.participantRemoved, - DisconnectReason.roomDeleted, - DisconnectReason.stateMismatch, - DisconnectReason.serverShutdown, - ].contains(event.reason.toSDKType())) { - fullReconnectOnNext = false; - await disconnect(); - } else { - await cleanUp(); - } + fullReconnectOnNext = false; + await disconnect(); events .emit(EngineDisconnectedEvent(reason: event.reason.toSDKType())); break; diff --git a/lib/src/core/room.dart b/lib/src/core/room.dart index 4426e2bf..201e12c2 100644 --- a/lib/src/core/room.dart +++ b/lib/src/core/room.dart @@ -518,17 +518,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable { notifyListeners(); }) ..on((event) async { - if (!engine.fullReconnectOnNext && - [ - DisconnectReason.signalingConnectionFailure, - DisconnectReason.joinFailure, - DisconnectReason.duplicateIdentity, - DisconnectReason.participantRemoved, - DisconnectReason.roomDeleted, - DisconnectReason.stateMismatch, - DisconnectReason.serverShutdown, - DisconnectReason.noInternetConnection - ].contains(event.reason)) { + if (!engine.fullReconnectOnNext) { await _cleanUp(); events.emit(RoomDisconnectedEvent(reason: event.reason)); notifyListeners();