W3cubDocs

/DOM

RTCPeerConnection.onsignalingstatechange

The onsignalingstatechange property of the RTCPeerConnection interface is an EventHandler which 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 value of RTCPeerConnection.signalingState changes, as the result of a call to either setLocalDescription() or setRemoteDescription().

Syntax

RTCPeerConnection.onsignalingstatechange = errorHandler;

Value

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.

Example

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
  }
};

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 56 15 22 ? 43
43
Promise based version.
37 — 43
?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 56 56 Yes 44 43
43
Promise based version.
37 — 43
? 6.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/onsignalingstatechange