Skip to content

Commit

Permalink
fix room.disconnect issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Jul 17, 2024
1 parent d1259ba commit a63b1af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/src/core/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
ConnectOptions? connectOptions,
RoomOptions? roomOptions,
FastConnectOptions? fastConnectOptions,
}) {
}) async {
roomOptions ??= this.roomOptions;
if (roomOptions.e2eeOptions != null) {
if (!lkPlatformSupportsE2EE()) {
throw LiveKitE2EEException('E2EE is not supported on this platform');
}
_e2eeManager = E2EEManager(roomOptions.e2eeOptions!.keyProvider);
_e2eeManager!.setup(this);
await _e2eeManager!.setup(this);

// Disable backup codec when e2ee is enabled
roomOptions = roomOptions.copyWith(
Expand All @@ -172,7 +172,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
);
}

return engine.connect(
await engine.connect(
url,
token,
connectOptions: connectOptions,
Expand Down Expand Up @@ -491,11 +491,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {

/// Disconnects from the room, notifying server of disconnection.
Future<void> disconnect() async {
if (engine.isClosed) {
if (engine.isClosed &&
engine.connectionState == ConnectionState.disconnected) {
events.emit(RoomDisconnectedEvent(reason: DisconnectReason.unknown));
return;
}
await engine.disconnect();
await _engineListener.waitFor<EngineDisconnectedEvent>(
duration: const Duration(seconds: 10));
await _cleanUp();
}

Expand Down

0 comments on commit a63b1af

Please sign in to comment.