From a60a2e861c5ce5c590888687f6a309f7ffeccd92 Mon Sep 17 00:00:00 2001 From: CloudWebRTC Date: Tue, 20 Sep 2022 17:47:38 +0800 Subject: [PATCH] chore: Add simulate for candidate protocol switch. (#176) --- example/lib/exts.dart | 1 + example/lib/widgets/controls.dart | 2 ++ lib/src/core/room.dart | 2 ++ lib/src/core/signal_client.dart | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/example/lib/exts.dart b/example/lib/exts.dart index aa1504af..956924dd 100644 --- a/example/lib/exts.dart +++ b/example/lib/exts.dart @@ -174,5 +174,6 @@ enum SimulateScenarioResult { nodeFailure, migration, serverLeave, + switchCandidate, clear, } diff --git a/example/lib/widgets/controls.dart b/example/lib/widgets/controls.dart index dcdfc9bd..203816cb 100644 --- a/example/lib/widgets/controls.dart +++ b/example/lib/widgets/controls.dart @@ -222,6 +222,8 @@ class _ControlsWidgetState extends State { nodeFailure: result == SimulateScenarioResult.nodeFailure ? true : null, migration: result == SimulateScenarioResult.migration ? true : null, serverLeave: result == SimulateScenarioResult.serverLeave ? true : null, + switchCandidate: + result == SimulateScenarioResult.switchCandidate ? true : null, ); } } diff --git a/lib/src/core/room.dart b/lib/src/core/room.dart index 8fe5d5f5..3c1520b5 100644 --- a/lib/src/core/room.dart +++ b/lib/src/core/room.dart @@ -575,12 +575,14 @@ extension RoomDebugMethods on Room { bool? nodeFailure, bool? migration, bool? serverLeave, + bool? switchCandidate, }) async { engine.signalClient.sendSimulateScenario( speakerUpdate: speakerUpdate, nodeFailure: nodeFailure, migration: migration, serverLeave: serverLeave, + switchCandidate: switchCandidate, ); } } diff --git a/lib/src/core/signal_client.dart b/lib/src/core/signal_client.dart index 688a31e9..c1fa1a72 100644 --- a/lib/src/core/signal_client.dart +++ b/lib/src/core/signal_client.dart @@ -438,6 +438,7 @@ extension SignalClientRequests on SignalClient { bool? nodeFailure, bool? migration, bool? serverLeave, + bool? switchCandidate, }) => _sendRequest(lk_rtc.SignalRequest( simulate: lk_rtc.SimulateScenario( @@ -445,6 +446,9 @@ extension SignalClientRequests on SignalClient { nodeFailure: nodeFailure, migration: migration, serverLeave: serverLeave, + switchCandidateProtocol: (switchCandidate != null && switchCandidate) + ? lk_rtc.CandidateProtocol.TCP + : null, ), )); }