We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

RTCDataChannelEvent()

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. Default is 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

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannelEvent' in that specification.
Candidate Recommendation Initial specification.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support57 ?22 ?44 ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support5757 ?2244 ?7.0

See also

Document Tags and Contributors

Contributors to this page: fscholz, Sheppy, teoli
Last updated by: fscholz,