onstatechange event handler for the RTCIceTransport interface is a property which specifies a function to serve as the EventHandler statechange event that is fired whenever the transport's state 改变。

句法

RTCIceTransport.onstatechange = stateChangeHandler;
					

Set this property to reference a function you provide that is called by the WebRTC layer when the RTCIceTransport 对象的 state 改变。

The event handler receives as its sole input an 事件 object describing the statechange event which occurred. To determine the new state, examine the value of state .

范例

This snippet establishes a handler for the statechange event that looks to see if the transport has entered the "failed" state, which indicates that the connection has failed with no chance of being automatically restored.

var iceTransport = pc.getSenders()[0].transport.iceTransport;
iceTransport.onstatechange = function(event) {
  if (iceTransport.state == "failed") {
    handleFailure(pc);
  }
}
					

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCIceTransport.onstatechange' in that specification.
候选推荐 最初的规范。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
onstatechange Chrome No Edge No Firefox No IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No

图例

不支持

不支持

另请参阅

元数据

  • 最后修改: