W3cubDocs

/DOM

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

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 22 (22) No support (Yes) ?
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 28 [1] 22.0 (22) No support No support No support (Yes)

[1] WebRTC, including RTCDataChannel, was introduced in Chrome 28 for Android behind a flag, and enabled by default starting in Chrome 29 for Android.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannelEvent/channel