Session migration (#72)
* impl * retry logic * simulate * pass checks * adjust log level * retry condition * fix simulate scenario params * format * use `RTCPeerConnectionState` instead of `RTCIceConnectionState` * adjust retry * additional check for completer * more logging * fix id * pub * change package * doc update * retry tests * format * apply suggestions
This commit is contained in:
@@ -154,4 +154,25 @@ extension LKExampleExt on BuildContext {
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Future<SimulateScenarioResult?> showSimulateScenarioDialog() =>
|
||||
showDialog<SimulateScenarioResult>(
|
||||
context: this,
|
||||
builder: (ctx) => SimpleDialog(
|
||||
title: const Text('Simulate Scenario'),
|
||||
children: SimulateScenarioResult.values
|
||||
.map((e) => SimpleDialogOption(
|
||||
child: Text(e.name),
|
||||
onPressed: () => Navigator.pop(ctx, e),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
enum SimulateScenarioResult {
|
||||
nodeFailure,
|
||||
migration,
|
||||
serverLeave,
|
||||
clear,
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:livekit_example/theme.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'pages/connect.dart';
|
||||
|
||||
void main() {
|
||||
void main() async {
|
||||
final format = DateFormat('HH:mm:ss');
|
||||
// configure logs for debugging
|
||||
Logger.root.level = Level.FINE;
|
||||
|
||||
@@ -149,6 +149,18 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onTapSimulateScenario() async {
|
||||
final result = await context.showSimulateScenarioDialog();
|
||||
if (result != null) {
|
||||
print('${result}');
|
||||
await widget.room.simulateScenario(
|
||||
nodeFailure: result == SimulateScenarioResult.nodeFailure ? true : null,
|
||||
migration: result == SimulateScenarioResult.migration ? true : null,
|
||||
serverLeave: result == SimulateScenarioResult.serverLeave ? true : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _onTapSendData() async {
|
||||
final result = await context.showSendDataDialog();
|
||||
if (result == true) {
|
||||
@@ -238,6 +250,11 @@ class _ControlsWidgetState extends State<ControlsWidget> {
|
||||
icon: const Icon(EvaIcons.settings2),
|
||||
tooltip: 'Subscribe permission',
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _onTapSimulateScenario,
|
||||
icon: const Icon(EvaIcons.alertTriangle),
|
||||
tooltip: 'Simulate scenario',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user