The onsignalingstatechange
event handler property of the RTCPeerConnection
interface specifies a function to be called when the signalingstatechange
event occurs on an RTCPeerConnection
interface. The function receives as input the event object of type Event
; this event is sent when the peer connection's signalingState
changes, which may happen either because of a call to setLocalDescription()
or to setRemoteDescription()
.
rtcPeerConnection.onsignalingstatechange = errorHandler;
Set this to a function which you provide that receives an Event
object as input; this contains the signalingstatechange
event. This event object doesn't provide details about what changed, but you can examine the signalingState
property to determine what the new state is.
You may also, as always, set up a handler for the signalingstatechange
event using addEventListener()
:
myRTCPeerConnection.addEventListener("signalingstatechange", mySignalingStateChangeHandler);
Or, using an anonymous (inline) handler:
myRTCPeerConnection.addEventListener("signalingstatechange", event => { /* handle the event here */ });
This snippet shows a handler for signalingstatechange
that looks for the "have-local-pranswer"
signaling state—indicating that a remote offer has been received and a local description of type "pranswer"
has been applied in response.
pc.onsignalingstatechange = function(event) { if (pc.signalingState === "have-local-pranswer") { // setLocalDescription() has been called with an answer } };
Specification |
---|
WebRTC 1.0: Real-Time Communication Between Browsers (WebRTC 1.0) # dom-rtcpeerconnection-onsignalingstatechange |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
onsignalingstatechange |
28 |
15 |
22 |
No |
15 |
11 |
≤37 |
28 |
44 |
15 |
11 |
1.5 |
signalingstatechange
event and its type, Event
.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/onsignalingstatechange