1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 14:59:22 +00:00

Get calls configuration

This commit is contained in:
Pierre HUBERT 2020-04-20 13:43:17 +02:00
parent 391d3150dd
commit 04693cc163
3 changed files with 29 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import 'package:comunic/helpers/websocket_helper.dart'; import 'package:comunic/helpers/websocket_helper.dart';
import 'package:comunic/models/call_config.dart';
/// Calls helper /// Calls helper
/// ///
@ -7,9 +8,17 @@ import 'package:comunic/helpers/websocket_helper.dart';
class CallsHelper { class CallsHelper {
/// Join a call /// Join a call
static Future<void> join(int convID) async => static Future<void> join(int convID) async =>
ws("calls/join", {"convID": convID}); await ws("calls/join", {"convID": convID});
/// Leave a call /// Leave a call
static Future<void> leave(int convID) async => static Future<void> leave(int convID) async =>
ws("calls/leave", {"convID": convID}); await ws("calls/leave", {"convID": convID});
/// Get calls configuration
static Future<CallConfig> getConfig() async {
final response = await ws("calls/config", {});
return CallConfig(
iceServers: response["iceServers"].cast<String>(),
);
}
} }

View File

@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
/// Call configuration
///
/// @author Pierre Hubert
class CallConfig {
final List<String> iceServers;
const CallConfig({
@required this.iceServers,
}) : assert(iceServers != null);
}

View File

@ -1,5 +1,6 @@
import 'package:comunic/helpers/calls_helper.dart'; import 'package:comunic/helpers/calls_helper.dart';
import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/models/call_config.dart';
import 'package:comunic/models/conversation.dart'; import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/ui/widgets/safe_state.dart';
@ -30,6 +31,7 @@ class _CallScreenState extends SafeState<CallScreen> {
// State properties // State properties
Conversation _conversation; Conversation _conversation;
String _convName; String _convName;
CallConfig _conf;
var _error = false; var _error = false;
@override @override
@ -58,6 +60,9 @@ class _CallScreenState extends SafeState<CallScreen> {
// Join the call // Join the call
await CallsHelper.join(convID); await CallsHelper.join(convID);
// Get call configuration
_conf = await CallsHelper.getConfig();
} catch (e, stack) { } catch (e, stack) {
print("Could not initialize call! $e\n$stack"); print("Could not initialize call! $e\n$stack");
setState(() => _error = true); setState(() => _error = true);