RTCDataChannelEvent()
The RTCDataChannelEvent() constructor creates a new RTCDataChannelEvent.
Note: 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 string which specifies the name of the event. There is only one type of
RTCDataChannelEvent, so this will always be"datachannel". rtcDataChannelEventInit-
An object with the following fields:
-
channelof typeRTCDataChannel, representing the data channel being concerned by the event. -
bubbles, optional, inherited fromEventInit. Indicates if the event must bubble or not.false. -
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 |
|---|
| WebRTC 1.0: Real-Time Communication Between Browsers (WebRTC 1.0) # dom-rtcdatachannelevent-constructor |
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 |
57 |
79 |
22 |
No |
44 |
11 |
57 |
57 |
22 |
43 |
11 |
7.0 |
See also
© 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/RTCDataChannelEvent