Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. RTCDataChannelEvent

RTCDataChannelEvent

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨January 2020⁩.

TheRTCDataChannelEvent interfacerepresents an event related to a specificRTCDataChannel.

Event RTCDataChannelEvent

Constructor

RTCDataChannelEvent()

Creates a newRTCDataChannelEvent.

Instance properties

Also inherits properties fromEvent.

channelRead only

Returns theRTCDataChannel associated with the event.

Examples

In this example, thedatachannel event handler is set up to save the data channel reference and set up handlers for the events which need to be monitored. Thechannel property provides theRTCDataChannel representing the connection to the other peer.

js
pc.ondatachannel = (event) => {  inboundDataChannel = event.channel;  inboundDataChannel.onmessage = handleIncomingMessage;  inboundDataChannel.onopen = handleChannelOpen;  inboundDataChannel.onclose = handleChannelClose;};

SeeA simple RTCDataChannel sample for another, more complete, example of how to use data channels.

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# rtcdatachannelevent

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp