--- title: RTCPeerConnection.connectionState slug: Web/API/RTCPeerConnection/connectionState translation_of: Web/API/RTCPeerConnection/connectionState ---
{{APIRef("WebRTC")}}
connectionState 只读,说明当前连接状态。状态值参见
RTCPeerConnectionState
,值由一个peer connection返回。
值变化时,一个connectionstatechange 事件发送给RTCPeerConnection对象实例中。
var connectionState = RTCPeerConnection.connectionState;
The current state of the connection, as a value from the enum RTCPeerConnectionState
.
{{page("/en-US/docs/Web/API/RTCPeerConnection", "RTCPeerConnectionState enum", 0, 1)}}
var pc = new RTCPeerConnection(configuration); /* ... */ var connectionState = pc.connectionState;
Specification | Status | Comment |
---|---|---|
{{ SpecName('WebRTC 1.0', '#widl-RTCPeerConnection-connectionState', 'RTCPeerConnection.connectionState') }} | {{ Spec2('WebRTC 1.0') }} | Initial specification. |
{{Compat("api.RTCPeerConnection.connectionState")}}