RTCDataChannelEvent
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。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 の例を参照してください。
仕様書
| 仕様書 |
|---|
| WebRTC: Real-Time Communication in Browsers> # rtcdatachannelevent> |
ブラウザーの互換性
関連情報
- WebRTC
RTCDataChannel- 単純な RTCDataChannel の例
RTCPeerConnection(datachannelイベントのターゲットインターフェイス)