1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-29 08:16:28 +00:00

Can send ice candidates to server

This commit is contained in:
Pierre HUBERT 2020-04-20 17:53:31 +02:00
parent ee6509bb9a
commit 7364fc49a8
2 changed files with 15 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import 'package:comunic/helpers/websocket_helper.dart';
import 'package:comunic/lists/call_members_list.dart'; import 'package:comunic/lists/call_members_list.dart';
import 'package:comunic/models/call_config.dart'; import 'package:comunic/models/call_config.dart';
import 'package:comunic/models/call_member.dart'; import 'package:comunic/models/call_member.dart';
import 'package:flutter_webrtc/rtc_ice_candidate.dart';
import 'package:flutter_webrtc/rtc_session_description.dart'; import 'package:flutter_webrtc/rtc_session_description.dart';
/// Calls helper /// Calls helper
@ -51,4 +52,14 @@ class CallsHelper {
"type": "SDP", "type": "SDP",
"data": jsonEncode(sdp.toMap()) "data": jsonEncode(sdp.toMap())
}); });
/// Send an IceCandidate
static Future<void> sendIceCandidate(
int callID, int peerID, RTCIceCandidate candidate) async =>
await ws("calls/signal", {
"callID": callID,
"peerID": peerID,
"type": "CANDIDATE",
"data": jsonEncode(candidate)
});
} }

View File

@ -168,6 +168,10 @@ class _CallScreenState extends SafeState<CallScreen> {
_peersConnections[memberID] = peerConnection; _peersConnections[memberID] = peerConnection;
// Register callbacks
peerConnection.onIceCandidate =
(c) => CallsHelper.sendIceCandidate(convID, memberID, c);
// Request an offer to establish a peer connection // Request an offer to establish a peer connection
await CallsHelper.requestOffer(convID, memberID); await CallsHelper.requestOffer(convID, memberID);
} catch (e, stack) { } catch (e, stack) {