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.
RTCPeerConnection.onconnectionstatechange = eventHandler;
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
事件
. 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.
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;
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.onconnectionstatechange' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onconnectionstatechange
|
Chrome 72 | Edge 79 | Firefox No | IE No | Opera No | Safari 11 | WebView Android 72 | Chrome Android 72 | Firefox Android No | Opera Android No | Safari iOS No | Samsung Internet Android 11.0 |
完整支持
不支持
connectionstatechange
event and its type,
事件
.
RTCPeerConnection
canTrickleIceCandidates
connectionState
currentLocalDescription
currentRemoteDescription
getDefaultIceServers()
iceConnectionState
iceGatheringState
localDescription
onaddstream
onconnectionstatechange
ondatachannel
onicecandidate
oniceconnectionstatechange
onicegatheringstatechange
onidentityresult
onidpassertionerror
onidpvalidationerror
onnegotiationneeded
onpeeridentity
onremovestream
onsignalingstatechange
ontrack
peerIdentity
pendingLocalDescription
pendingRemoteDescription
remoteDescription
sctp
signalingState
addIceCandidate()
addStream()
addTrack()
close()
createAnswer()
createDataChannel()
createOffer()
generateCertificate()
getConfiguration()
getIdentityAssertion()
getReceivers()
getSenders()
getStats()
getStreamById()
getTransceivers()
removeStream()
removeTrack()
restartIce()
setConfiguration()
setIdentityProvider()
setLocalDescription()
setRemoteDescription()
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent