RTCPeerConnection.onsignalingstatechange

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The RTCPeerConnection.onsignalingstatechange property 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

pc.onsignalingstatechange = function(event) {
  if (pc.signalingState === "have-local-pranswer") {
    // setLocalDescription() has been called with an answer
  }
};

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.onsignalingstatechange' in that specification.
Working Draft Initial specification.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) [1] (Yes) 24 (24)[2]
36.0 (36.0)[3]
No support (Yes) ?
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) [1] (Yes) [1] (Yes) 24 (24)[2]
36.0 (36.0)[3]
No support ? ?

[1] Though this property is not prefixed, the interface it belongs to was until Chrome 56.

[2] Though this property isn't prefixed, the RTCPeerConnection interface of which it's a member was prefixed (as MozRTCPeerConnection) until Firefox 44.

[3] Before Firefox 36, the event handler was passed the signaling state value (one of the values in the RTCSignalingState enum) instead of the event as required by the specification. This has been fixed.

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, abbycar, Sheppy, Sebastianz, teoli
 Last updated by: jpmedley,