RTCDataChannel.readyState

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

The read-only property RTCDataChannel.readyState returns an enum of the type RTCDataChannelState representing the state of the underlying data connection.

Syntax

var state = dataChannel.readyState;

The possible values are:

  • "connecting" is the state indicating that the underlying connection is not yet set up and active. This is the initial state of a data channel created with RTCPeerConnection.createDataChannel().
  • "open" is the state indicating that the underlying connection is up and running. This is the initial state of a data channel dispatched in a RTCDataChannelEvent.
  • "closing" is the state indicating that the underlying connection is in the process of shutting down. No new sending task is accepting but the cached messages are in the process of being sent, or received.
  • "closed" is the state indicating that the underlying connection has been shut down (or couldn't be established).

Example

var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");

console.log("Channel state: " + dc.readyState);

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browser
The definition of 'RTCDataChannel.readyState' in that specification.
Working Draft Initial specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) [1] Not supported (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? Not supported ? ?

[1] The interface is called DataChannel and not RTCDataChannel

See also

Document Tags and Contributors

 Contributors to this page: teoli
 Last updated by: teoli,