Web/API/RTCDataChannelEvent/channel

From Get docs

This is an experimental technologyCheck 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 BrowsersThe definition of 'RTCDataChannelEvent.channel' in that specification. Candidate Recommendation Initial specification.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
channel Chrome

Full support Yes

Edge

Full support ≤79

Firefox

Full support 22

IE

No support No

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support 28

Firefox Android

Full support 22

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support 1.5

Legend

Full support  
Full support
No support  
No support


See also