This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The RTCDataChannelEvent()
constructor creates a new RTCDataChannelEvent
.
You will rarely if ever construct an RTCDataChannelEvent
by hand; these events are normally created and sent by the WebRTC layer itself.
Syntax
var event = new RTCDataChannelEvent(type, rtcDataChannelEventInit);
Parameters
type
- A
DOMString
which specifies the name of the event. There is only one type ofRTCDataChannelEvent
, so this will always be"datachannel"
. rtcDataChannelEventInit
- A
RTCDataChannelEventInit
dictionary, which has following fields:"channel"
of typeRTCDataChannel
, representing the data channel being concerned by the event."bubbles"
, optional, inherited fromEventInit
. Indicates if the event must bubble or not. Default isfalse
."cancelable"
, optional, inherited fromEventInit
. Indicates if the event can be canceled or not. Default is false.
Value
A new RTCDataChannelEvent
configured as specified.
Example
In this example, a new datachannel
event is created. dc
is a data channel which already exists.
var event = new RTCDataChannelEvent("datachannel", {"channel": dc});
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCDataChannelEvent' in that specification. |
Candidate Recommendation | Initial specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCDataChannelEvent() constructor | Chrome Full support 57 | Edge Full support ≤79 | Firefox Full support 22 | IE No support No | Opera Full support 44 | Safari ? | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android Full support 22 | Opera Android Full support 43 | Safari iOS ? | Samsung Internet Android Full support 7.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown