Skip to content

Commit

Permalink
Merge branch 'main' into improve-reconnect-logic-for-websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc authored Dec 11, 2023
2 parents 2cd9aa7 + f5c681d commit 25b6065
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/src/core/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {

logger.fine('Waiting for engine to connect...');

// wait until engine is connected
// wait until primary pc is connected
await events.waitFor<EnginePeerStateUpdatedEvent>(
filter: (event) => event.isPrimary && event.state.isConnected(),
duration: this.connectOptions.timeouts.connection,
onTimeout: () => throw ConnectException(
'Timed out waiting for EnginePeerStateUpdatedEvent'),
onTimeout: () => throw MediaConnectException(
'Timed out waiting for PeerConnection to connect, please check your network for ice connectivity'),
);

_updateConnectionState(ConnectionState.connected);
Expand Down Expand Up @@ -631,6 +631,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
await events.waitFor<EnginePeerStateUpdatedEvent>(
filter: (event) => event.isPrimary && event.state.isConnected(),
duration: connectOptions.timeouts.peerConnection,
onTimeout: () => throw MediaConnectException('ice restart failed'),
);
logger.fine('resumeConnection: primary connected');
}
Expand Down
9 changes: 9 additions & 0 deletions lib/src/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ class ConnectException extends LiveKitException {
ConnectException([String msg = 'Failed to connect to server']) : super._(msg);
}

/// An exception occured while attempting to disconnect.
/// Common reasons:
/// - Network condition is not good.
/// - SFU deploy behind a NAT and not configured correctly.
/// - Need a turn relay server but not configured.
class MediaConnectException extends LiveKitException {
MediaConnectException([String msg = 'Ice connection failed']) : super._(msg);
}

/// An internal state of the SDK is not correct and can not continue to execute.
/// This should not occur frequently.
class UnexpectedStateException extends LiveKitException {
Expand Down
1 change: 1 addition & 0 deletions lib/src/publication/track_publication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ abstract class TrackPublication<T extends Track> extends Disposable {
'${this} Sending mute signal... sid:${sid}, muted:${event.muted}');
participant.room.engine.signalClient.sendMuteTrack(sid, event.muted);
}
_metadataMuted = event.muted;
// emit events
final newEvent = event.muted
? TrackMutedEvent(participant: participant, publication: this)
Expand Down

0 comments on commit 25b6065

Please sign in to comment.