只读
connectionState
特性为
RTCPeerConnection
interface indicates the current state of the peer connection by returning one of the string values specified by the enum
RTCPeerConnectionState
.
When this property's value changes, a
connectionstatechange
event is sent to the
RTCPeerConnection
实例。
var connectionState = RTCPeerConnection.connectionState;
The current state of the connection, as a value from the enum
RTCPeerConnectionState
.
RTCPeerConnectionState
enum defines string constants which describe states in which the
RTCPeerConnection
may be. These values are returned by the
connectionState
property. This state essentially represents the aggregate state of all ICE transports (which are of type
RTCIceTransport
or
RTCDtlsTransport
) being used by the connection.
| 常量 | 描述 |
|---|---|
"new"
|
At least one of the connection's ICE transports (
RTCIceTransport
s or
RTCDtlsTransport
s) are in the
"new"
state, and none of them are in one of the following states:
"connecting"
,
"checking"
,
"failed"
,或
"disconnected"
,
or
all of the connection's transports are in the
"closed"
状态。
|
"connecting"
|
One or more of the ICE transports are currently in the process of establishing a connection; that is, their
RTCIceConnectionState
是
"checking"
or
"connected"
, and no transports are in the
"failed"
状态。
<<< Make this a link once I know where that will be documented
|
"connected"
|
Every ICE transport used by the connection is either in use (state
"connected"
or
"completed"
) or is closed (state
"closed"
); in addition, at least one transport is either
"connected"
or
"completed"
.
|
"disconnected"
|
At least one of the ICE transports for the connection is in the
"disconnected"
state and none of the other transports are in the state
"failed"
,
"connecting"
,或
"checking"
.
|
"failed"
|
One or more of the ICE transports on the connection is in the
"failed"
状态。
|
"closed"
|
RTCPeerConnection
is closed.
This value was in the
|
var pc = new RTCPeerConnection(configuration); /* ... */ var connectionState = pc.connectionState;
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCPeerConnection.connectionState' in that specification. |
候选推荐 | 最初的规范。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
connectionState
|
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 |
完整支持
不支持
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