RTCPeerConnection.onsignalingstatechange - Web APIs 编辑

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().

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.

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 */
});

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

SpecificationStatusComment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.onsignalingstatechange' in that specification.
Candidate RecommendationInitial specification.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:90 次

字数:4640

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文