RTCPeerConnection.connectionState - Web API 接口参考 编辑

 

connectionState 只读,说明当前连接状态。状态值参见RTCPeerConnectionState ,值由一个peer connection返回。

值变化时,一个connectionstatechange 事件发送给RTCPeerConnection对象实例中。

Syntax

var connectionState = RTCPeerConnection.connectionState;

Value

The current state of the connection, as a value from the enum RTCPeerConnectionState.

RTCPeerConnectionState enum

The 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.

ConstantDescription
"new"At least one of the connection's ICE transports (RTCIceTransports or RTCDtlsTransports) are in the "new" state, and none of them are in one of the following states: "connecting", "checking", "failed", or "disconnected", or all of the connection's transports are in the "closed" state.
"connecting"One or more of the ICE transports are currently in the process of establishing a connection; that is, their RTCIceConnectionState is either "checking" or "connected", and no transports are in the "failed" state. <<< 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", or "checking".
"failed"One or more of the ICE transports on the connection is in the "failed" state.
"closed"

The RTCPeerConnection is closed.

This value was in the RTCSignalingState enum (and therefore found by reading the value of the signalingState) property until the May 13, 2016 draft of the specification.

Example

var pc = new RTCPeerConnection(configuration);

/* ... */

var connectionState = pc.connectionState;

Specifications

SpecificationStatusComment
WebRTC 1.0: Real-time Communication Between Browsers
RTCPeerConnection.connectionState
Candidate RecommendationInitial specification.

Browser compatibility

BCD tables only load in the browser

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.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:56 次

字数:5913

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文