建構函式
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:瀏覽器中的即時通訊 # rtcdatachannelevent |
瀏覽器相容性
載入中…