RTCPeerConnection.onconnectionstatechange - Web APIs 编辑
The RTCPeerConnection.onconnectionstatechange
property specifies an EventHandler
which is called to handle the connectionstatechange
event when it occurs on an instance of RTCPeerConnection
. This happens whenever the aggregate state of the connection changes. The aggregate state is a combination of the states of all of the individual network transports being used by the connection.
Syntax
RTCPeerConnection.onconnectionstatechange = eventHandler;
Value
A function which is called by the browser when the connectionstatechange
event occurs on the RTCPeerConnection
. The function receives as input a single parameter, which is an object of type Event
. The event object contains no special information of note; you can look at the value of the peer connection's connectionState
property to determine what the new state is.
Example
pc.onconnectionstatechange = function(event) {
switch(pc.connectionState) {
case "connected":
// The connection has become fully connected
break;
case "disconnected":
case "failed":
// One or more transports has terminated unexpectedly or in an error
break;
case "closed":
// The connection has been closed
break;
}
}
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCPeerConnection.onconnectionstatechange' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
BCD tables only load in the browser
See also
- The
connectionstatechange
event and its type,Event
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论