Nuestros voluntarios aún no han traducido este artículo al Español. Únete a nosotros y ayúdanos a traducirlo
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage 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 specification changes.
The RTCDataChannelEvent()
constructor returns a new RTCDataChannelEvent
object, which represents a datachannel
event. These events sent to an RTCPeerConnection
when its remote peer is asking to open an RTCDataChannel
between the two peers.
You will rarely if ever construct an RTCDataChannelEvent
by hand; instead, the WebRTC layer will generate and deliver them to you at the appropriate time. Just listen for the datachannel
event and when you receive it, use the RTCDataChannelEvent.channel
property to gain access to the data channel which has been opened.
Constructor
RTCDataChannelEvent()
- The
RTCDataChannelEvent()
constructor creates a newRTCDataChannelEvent
. channel
Read only- The read-only property
RTCDataChannelEvent
.channel
returns theRTCDataChannel
associated with the event. - WebRTC
RTCDataChannel
RTCDataChannel.ondatachannel
- A simple RTCDataChannel sample
RTCPeerConnection
(the target interface fordatachannel
events)
Properties
Also inherits properties from: Event
Methods
This interface has no methods, but inherits methods from: Event
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browser The definition of 'RTCPeerConnection()' in that specification. |
Working Draft | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes) | 22 (22) | ? | ? | ? |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | No support | No support | 24.0 (24) | ? | ? | ? | ? | (Yes) |
See also
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 | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browser The definition of 'RTCDataChannelEvent' in that specification. |
Working Draft | Initial definition. |
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.