这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
RTCDataChannelEvent()
constructor returns a new
RTCDataChannelEvent
object, which represents a
datachannel
event. These events sent to an
RTCPeerConnection
when its remote peer is asking to open an
RTCDataChannel
between the two peers.
You will rarely if ever construct an
RTCDataChannelEvent
by hand; instead, the WebRTC layer will generate and deliver them to you at the appropriate time. Just listen for the
datachannel
event to be received by the
RTCPeerConnection
and when you receive it, use the
RTCDataChannelEvent.channel
property to gain access to the data channel which has been opened.
RTCDataChannelEvent()
RTCDataChannelEvent()
构造函数创建新
RTCDataChannelEvent
.
Also inherits properties from:
事件
channel
只读
RTCDataChannelEvent
.channel
返回
RTCDataChannel
与事件关联。
This interface has no methods, but inherits methods from:
事件
在此范例中,
datachannel
event handler is set up to save the data channel reference and set up handlers for the events which need to be monitored. The
channel
property provides the
RTCDataChannel
representing the connection to the other peer.
pc.ondatachannel = function(event) {
inboundDataChannel = event.channel;
inboundDataChannel.onmessage = handleIncomingMessage;
inboundDataChannel.onopen = handleChannelOpen;
inboundDataChannel.onclose = handleChannelClose;
}
见 A simple RTCDataChannel sample for another, more complete, example of how to use data channels.
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannelEvent' in that specification. |
候选推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
RTCDataChannelEvent
|
Chrome Yes | Edge ≤79 | Firefox 22 | IE No | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android 28 | Firefox Android 22 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 1.5 |
RTCDataChannelEvent()
构造函数
|
Chrome 57 | Edge ≤79 | Firefox 22 | IE No | Opera 44 | Safari ? | WebView Android 57 | Chrome Android 57 | Firefox Android 22 | Opera Android 43 | Safari iOS ? | Samsung Internet Android 7.0 |
channel
|
Chrome Yes | Edge ≤79 | Firefox 22 | IE No | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android 28 | Firefox Android 22 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 1.5 |
完整支持
不支持
兼容性未知
RTCDataChannel
RTCDataChannel.ondatachannel
RTCPeerConnection
(the target interface for
datachannel
events)
RTCDataChannelEvent
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannel
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnection
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent