WebRTC
The RTCDataChannelEvent() constructor
creates a new RTCDataChannelEvent object.
[!NOTE] You will rarely if ever construct an
RTCDataChannelEventby hand; these events are normally created and sent by the WebRTC layer itself.
Syntax
new RTCDataChannelEvent(type, options)
Parameters
type- : A string with the name of the event.
It is case-sensitive and browsers always set it to
datachannel.
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
options- : An object that, in addition of the properties defined in Event/Event, can have the following properties:
channel- : A RTCDataChannel, representing the data channel being associated with the event.
- : An object that, in addition of the properties defined in Event/Event, can have the following properties:
Return value
A new RTCDataChannelEvent object configured as specified.
Example
In this example, a new RTCPeerConnection.datachannel_event event is created. dc is a
data channel which already exists.
const event = new RTCDataChannelEvent("datachannel", { channel: dc });
Specifications
Browser compatibility
See also
- WebRTC
- RTCDataChannel
- RTCPeerConnection
- A simple RTCDataChannel sample
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
