Skip to content

Commit

Permalink
Merge pull request #8 from tauu/addCandidate-promise
Browse files Browse the repository at this point in the history
switch to promise version of addIceCandidate to fix running on Firefox / Safari
  • Loading branch information
cloudwebrtc authored Jan 9, 2022
2 parents 83fc41e + f5318df commit 9d42101
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions lib/src/rtc_peerconnection_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,9 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
}

@override
Future<void> addCandidate(RTCIceCandidate candidate) async {
try {
Completer completer = Completer<void>();
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<void> addCandidate(RTCIceCandidate candidate) {
return jsutil.promiseToFuture<void>(
jsutil.callMethod(_jsPc, 'addIceCandidate', [_iceToJs(candidate)]));
}

@override
Expand Down

0 comments on commit 9d42101

Please sign in to comment.