Skip to content

Commit

Permalink
switch to promise version of addIceCandidate
Browse files Browse the repository at this point in the history
  • Loading branch information
tauu committed Jan 8, 2022
1 parent 83fc41e commit f5318df
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 f5318df

Please sign in to comment.