RTCDataChannelEvent
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.
RTCDataChannelEvent インターフェイスは、特定の RTCPeerConnection に関連するイベントを表します。
コンストラクター
RTCDataChannelEvent()-
新しい
RTCDataChannelEventを作成します。
インスタンスプロパティ
Event のプロパティを継承しています。
channel読取専用-
このイベントに関連付けられた
RTCDataChannelを返します。
例
この例では、 datachannel イベントハンドラーを設定して、データチャンネルの参照を保存し、監視する必要があるイベントのハンドラーを設定しています。 channel プロパティは、他にもピアへの接続を表す RTCDataChannel を提供しています。
js
pc.ondatachannel = (event) => {
inboundDataChannel = event.channel;
inboundDataChannel.onmessage = handleIncomingMessage;
inboundDataChannel.onopen = handleChannelOpen;
inboundDataChannel.onclose = handleChannelClose;
};
データチャンネルを使用する、より完全な別の例は、単純な RTCDataChannel の例を参照してください。
仕様書
| Specification |
|---|
| WebRTC: Real-Time Communication in Browsers> # rtcdatachannelevent> |
ブラウザーの互換性
Loading…
関連情報
- WebRTC
RTCDataChannel- 単純な RTCDataChannel の例
RTCPeerConnection(datachannelイベントのターゲットインターフェイス)