RTCDataChannelEvent.channel

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The read-only property RTCDataChannelEvent.channel returns the RTCDataChannel associated with the event.

Syntax

 var channel = RTCDataChannelEvent.channel;

Value

A RTCDataChannel object representing the data channel linking the receiving RTCPeerConnection to its remote peer.

Example

The first line of code in the datachannel event handler shown below takes the channel from the event object and saves it locally for use by the code handling data traffic.

pc.ondatachannel = function(event) {
  inboundDataChannel = event.channel;
  inboundDataChannel.onmessage = handleIncomingMessage;
  inboundDataChannel.onopen = handleChannelOpen;
  inboundDataChannel.onclose = handleChannelClose;
}

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannelEvent.channel' in that specification.
Candidate Recommendation Initial specification.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
channelChrome Full support YesEdge Full support ≤79Firefox Full support 22IE No support NoOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support 28Firefox Android Full support 22Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.5

Legend

Full support
Full support
No support
No support

See also