8000 [Web] Fix events callback for peerconnection. · next-coder/flutter-webrtc@9bdc491 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bdc491

Browse files
committed
[Web] Fix events callback for peerconnection.
1 parent bc8e3ce commit 9bdc491

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/src/web/rtc_peerconnection_impl.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,10 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
7272
onIceConnectionState?.call(_iceConnectionState);
7373
});
7474

75-
js.JsObject.fromBrowserObject(_jsPc)['onicegatheringstatechange'] =
76-
js.JsFunction.withThis((_) {
75+
jsutil.setProperty(_jsPc, 'onicegatheringstatechange', js.allowInterop((_) {
7776
_iceGatheringState = iceGatheringStateforString(_jsPc.iceGatheringState);
7877
onIceGatheringState?.call(_iceGatheringState);
79-
});
78+
}));
8079

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

91-
js.JsObject.fromBrowserObject(_jsPc)['connectionstatechange'] =
92-
js.JsFunction.withThis((_, state) {
93-
_connectionState = peerConnectionStateForString(state);
90+
_jsPc.onIceConnectionStateChange.listen((_) {
91+
_connectionState = peerConnectionStateForString(_jsPc.iceConnectionState);
9492
onConnectionState?.call(_connectionState);
9593
});
9694

97-
js.JsObject.fromBrowserObject(_jsPc)['negotiationneeded'] =
98-
js.JsFunction.withThis(() {
95+
_jsPc.onNegotiationNeeded.listen((_) {
9996
onRenegotiationNeeded?.call();
10097
});
10198

0 commit comments

Comments
 (0)
0