W3cubDocs

/DOM

RTCDataChannelEvent.constructor

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 of RTCDataChannelEvent, so this will always be "datachannel".
rtcDataChannelEventInit
A RTCDataChannelEventInit dictionary, which has following fields:
  • "channel" of type RTCDataChannel, representing the data channel being concerned by the event.
  • "bubbles", optional, inherited from EventInit. Indicates if the event must bubble or not. false.
  • "cancelable", optional, inherited from EventInit. 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

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.

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannelEvent/RTCDataChannelEvent