From f5318dfdf532c5f992273982b3872c68d15ce03a Mon Sep 17 00:00:00 2001 From: Georg Wechslberger Date: Sat, 8 Jan 2022 17:17:50 +0100 Subject: [PATCH] switch to promise version of addIceCandidate --- lib/src/rtc_peerconnection_impl.dart | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/src/rtc_peerconnection_impl.dart b/lib/src/rtc_peerconnection_impl.dart index 8778146..8afcb26 100644 --- a/lib/src/rtc_peerconnection_impl.dart +++ b/lib/src/rtc_peerconnection_impl.dart @@ -227,18 +227,9 @@ class RTCPeerConnectionWeb extends RTCPeerConnection { } @override - Future addCandidate(RTCIceCandidate candidate) async { - try { - Completer completer = Completer(); - var success = js.allowInterop(() => completer.complete()); - var failure = js.allowInterop((e) => completer.completeError(e)); - jsutil.callMethod( - _jsPc, 'addIceCandidate', [_iceToJs(candidate), success, failure]); - - return completer.future; - } catch (e) { - print(e.toString()); - } + Future addCandidate(RTCIceCandidate candidate) { + return jsutil.promiseToFuture( + jsutil.callMethod(_jsPc, 'addIceCandidate', [_iceToJs(candidate)])); } @override