Skip to content

Commit

Permalink
[Web] Fix events callback for peerconnection.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Nov 25, 2020
1 parent bc8e3ce commit 9bdc491
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/src/web/rtc_peerconnection_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
onIceConnectionState?.call(_iceConnectionState);
});

js.JsObject.fromBrowserObject(_jsPc)['onicegatheringstatechange'] =
js.JsFunction.withThis((_) {
jsutil.setProperty(_jsPc, 'onicegatheringstatechange', js.allowInterop((_) {
_iceGatheringState = iceGatheringStateforString(_jsPc.iceGatheringState);
onIceGatheringState?.call(_iceGatheringState);
});
}));

_jsPc.onRemoveStream.listen((mediaStreamEvent) {
final _remoteStream = _remoteStreams.remove(mediaStreamEvent.stream.id);
Expand All @@ -88,14 +87,12 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
onSignalingState?.call(_signalingState);
});

js.JsObject.fromBrowserObject(_jsPc)['connectionstatechange'] =
js.JsFunction.withThis((_, state) {
_connectionState = peerConnectionStateForString(state);
_jsPc.onIceConnectionStateChange.listen((_) {
_connectionState = peerConnectionStateForString(_jsPc.iceConnectionState);
onConnectionState?.call(_connectionState);
});

js.JsObject.fromBrowserObject(_jsPc)['negotiationneeded'] =
js.JsFunction.withThis(() {
_jsPc.onNegotiationNeeded.listen((_) {
onRenegotiationNeeded?.call();
});

Expand Down

0 comments on commit 9bdc491

Please sign in to comment.