Skip to content

Commit 0fcc341

Browse files
authored
Improve reconnect logic for websocket (#406)
* Capture possible exceptions when closing the room at any time and the internal process is busy. * fix. * imporve reconnect logic. * fix canReconnect logic on SignalLeaveEvent. * Monitor Connectivity changes and automatically reconnect. * update. * Improve PCs reconnection speed. * support Manual subscription. * update. * simple grid view for test. * update pubspec. * Fixed handleParticipantDisconnect not emitting for existing partcicpant. * Trigger full Reconnect when peerConnection Failed. * update grid view. * add checkIfDesposed. * update. * remove checkIfDisposed. * fixed rendering exception. * update. * update. * fix flutter analyze. * fix reconnect test. * update. * update. * revert changes for example app. * update. * Refactored reconnect logic to support connectivity/network change checking. * update. * update. * cleanup. * cleanup. * sendLeave for room.disconnect. * fix for web. * fix for web. * dart run import_sorter:main. * update. * fix.
1 parent ffb4301 commit 0fcc341

File tree

16 files changed

+520
-330
lines changed

16 files changed

+520
-330
lines changed

example/lib/exts.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ extension LKExampleExt on BuildContext {
208208

209209
enum SimulateScenarioResult {
210210
signalReconnect,
211+
fullReconnect,
212+
speakerUpdate,
211213
nodeFailure,
212214
migration,
213215
serverLeave,
214216
switchCandidate,
215-
clear,
216217
e2eeKeyRatchet,
217218
participantName,
218219
participantMetadata,
220+
clear,
219221
}

example/lib/pages/room.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class _RoomPageState extends State<RoomPage> {
9696
})
9797
..on<LocalTrackPublishedEvent>((_) => _sortParticipants())
9898
..on<LocalTrackUnpublishedEvent>((_) => _sortParticipants())
99+
..on<TrackSubscribedEvent>((_) => _sortParticipants())
100+
..on<TrackUnsubscribedEvent>((_) => _sortParticipants())
99101
..on<TrackE2EEStateEvent>(_onE2EEStateEvent)
100102
..on<ParticipantNameUpdatedEvent>((event) {
101103
print(

example/lib/widgets/controls.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,12 @@ class _ControlsWidgetState extends State<ControlsWidget> {
250250
}
251251

252252
await widget.room.sendSimulateScenario(
253+
speakerUpdate:
254+
result == SimulateScenarioResult.speakerUpdate ? 3 : null,
253255
signalReconnect:
254256
result == SimulateScenarioResult.signalReconnect ? true : null,
257+
fullReconnect:
258+
result == SimulateScenarioResult.fullReconnect ? true : null,
255259
nodeFailure: result == SimulateScenarioResult.nodeFailure ? true : null,
256260
migration: result == SimulateScenarioResult.migration ? true : null,
257261
serverLeave: result == SimulateScenarioResult.serverLeave ? true : null,

example/pubspec.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ dependencies:
2121
flutter_svg: ^2.0.5
2222
dropdown_button2: ^2.3.6
2323
flutter_window_close: ^0.2.2
24+
collection: '>=1.16.0'
2425

2526
livekit_client:
2627
path: ../
27-
# git:
28-
# url: https://github.com/livekit/client-sdk-flutter
29-
# ref: main
3028

3129
dev_dependencies:
3230
flutter_test:

0 commit comments

Comments
 (0)