Skip to content

Commit ab7a682

Browse files
authored
Fix signal resume events (#1027)
Emit RoomReconnectedEvent after signal resume. Fix _sendSyncState() timing to run after WS reconnects instead of before. Add RoomResumingEvent separate from RoomReconnectingEvent with shared ReconnectingEvent base mixin.
1 parent 85dc99d commit ab7a682

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

.changes/fix-signal-resume-events

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patch type="fixed" "Fix missing RoomReconnectedEvent and incorrect SyncState timing during signal-only reconnection"

lib/src/core/room.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
499499
..on<EngineResumedEvent>((event) async {
500500
// re-send tracks permissions
501501
localParticipant?.sendTrackSubscriptionPermissions();
502+
events.emit(const RoomReconnectedEvent());
502503
notifyListeners();
503504
})
504505
..on<EngineFullRestartingEvent>((event) async {
@@ -536,9 +537,12 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
536537
notifyListeners();
537538
})
538539
..on<EngineResumingEvent>((event) async {
539-
await _sendSyncState();
540+
events.emit(const RoomResumingEvent());
540541
notifyListeners();
541542
})
543+
..on<SignalReconnectedEvent>((event) async {
544+
await _sendSyncState();
545+
})
542546
..on<EngineAttemptReconnectEvent>((event) async {
543547
events.emit(RoomAttemptReconnectEvent(
544548
attempt: event.attempt,

lib/src/events.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,30 @@ class RoomConnectedEvent with RoomEvent {
6666
String toString() => '${runtimeType}(room: ${room}, metadata: ${metadata})';
6767
}
6868

69+
/// Base type for reconnecting events. Listen for this type to handle
70+
/// both full reconnects and signal-only reconnects.
71+
mixin ReconnectingEvent implements RoomEvent {}
72+
6973
/// When the connection to the server has been interrupted and it's attempting
70-
/// to reconnect.
74+
/// a full reconnect (peer connections are reset, media is interrupted).
7175
/// Emitted by [Room].
72-
class RoomReconnectingEvent with RoomEvent {
76+
class RoomReconnectingEvent with RoomEvent, ReconnectingEvent {
7377
const RoomReconnectingEvent();
7478

7579
@override
7680
String toString() => '${runtimeType}()';
7781
}
7882

83+
/// When the signal connection has been interrupted and it's attempting
84+
/// to resume. Peer connections remain active during this type of reconnect.
85+
/// Emitted by [Room].
86+
class RoomResumingEvent with RoomEvent, ReconnectingEvent {
87+
const RoomResumingEvent();
88+
89+
@override
90+
String toString() => '${runtimeType}()';
91+
}
92+
7993
/// report the number of attempts to reconnect to the room.
8094
class RoomAttemptReconnectEvent with RoomEvent {
8195
final int attempt;

0 commit comments

Comments
 (0)