RTCDataChannelEvent
The RTCDataChannelEvent interface represents an event related to a specific RTCDataChannel.
Constructor
RTCDataChannelEvent()-
Creates a new
RTCDataChannelEvent.
Properties
Also inherits properties from Event.
-
channelRead only -
Returns the
RTCDataChannelassociated with the event.
Examples
In this example, the datachannel event handler is set up to save the data channel reference and set up handlers for the events which need to be monitored. The channel property provides the RTCDataChannel representing the connection to the other peer.
pc.ondatachannel = function(event) { inboundDataChannel = event.channel; inboundDataChannel.onmessage = handleIncomingMessage; inboundDataChannel.onopen = handleChannelOpen; inboundDataChannel.onclose = handleChannelClose; }
See A simple RTCDataChannel sample for another, more complete, example of how to use data channels.
Specifications
| Specification |
|---|
| WebRTC 1.0: Real-Time Communication Between Browsers (WebRTC 1.0) # rtcdatachannelevent |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
RTCDataChannelEvent |
Yes |
79 |
22 |
No |
Yes |
11 |
Yes |
28 |
22 |
Yes |
11 |
1.5 |
RTCDataChannelEvent |
57 |
79 |
22 |
No |
44 |
11 |
57 |
57 |
22 |
43 |
11 |
7.0 |
channel |
Yes |
79 |
22 |
No |
Yes |
11 |
Yes |
28 |
22 |
Yes |
11 |
1.5 |
See also
- WebRTC
RTCDataChannelRTCPeerConnection.ondatachannel- A simple RTCDataChannel sample
-
RTCPeerConnection(the target interface fordatachannelevents)
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannelEvent