Skip to content

Commit

Permalink
Improve reconnect logic for websocket (#406)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
cloudwebrtc authored Dec 21, 2023
1 parent ffb4301 commit 0fcc341
Show file tree
Hide file tree
Showing 16 changed files with 520 additions and 330 deletions.
4 changes: 3 additions & 1 deletion example/lib/exts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,14 @@ extension LKExampleExt on BuildContext {

enum SimulateScenarioResult {
signalReconnect,
fullReconnect,
speakerUpdate,
nodeFailure,
migration,
serverLeave,
switchCandidate,
clear,
e2eeKeyRatchet,
participantName,
participantMetadata,
clear,
}
2 changes: 2 additions & 0 deletions example/lib/pages/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class _RoomPageState extends State<RoomPage> {
})
..on<LocalTrackPublishedEvent>((_) => _sortParticipants())
..on<LocalTrackUnpublishedEvent>((_) => _sortParticipants())
..on<TrackSubscribedEvent>((_) => _sortParticipants())
..on<TrackUnsubscribedEvent>((_) => _sortParticipants())
..on<TrackE2EEStateEvent>(_onE2EEStateEvent)
..on<ParticipantNameUpdatedEvent>((event) {
print(
Expand Down
4 changes: 4 additions & 0 deletions example/lib/widgets/controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,12 @@ class _ControlsWidgetState extends State<ControlsWidget> {
}

await widget.room.sendSimulateScenario(
speakerUpdate:
result == SimulateScenarioResult.speakerUpdate ? 3 : null,
signalReconnect:
result == SimulateScenarioResult.signalReconnect ? true : null,
fullReconnect:
result == SimulateScenarioResult.fullReconnect ? true : null,
nodeFailure: result == SimulateScenarioResult.nodeFailure ? true : null,
migration: result == SimulateScenarioResult.migration ? true : null,
serverLeave: result == SimulateScenarioResult.serverLeave ? true : null,
Expand Down
4 changes: 1 addition & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ dependencies:
flutter_svg: ^2.0.5
dropdown_button2: ^2.3.6
flutter_window_close: ^0.2.2
collection: '>=1.16.0'

livekit_client:
path: ../
# git:
# url: https://github.com/livekit/client-sdk-flutter
# ref: main

dev_dependencies:
flutter_test:
Expand Down
Loading

0 comments on commit 0fcc341

Please sign in to comment.