The WebRTC
open
event is sent to an
RTCDataChannel
对象的
onopen
event handler when the underlying transport used to send and receive the data channel's messages is opened or re-opened.
| 冒泡 | No |
|---|---|
| 可取消 | No |
| 接口 |
RTCDataChannelEvent
|
| 事件处理程序特性 |
onopen
|
This example adds to the
RTCDataChannel
dc
a handler for the
open
event that adjusts the user interface to indicate that a chat window is ready to be used after a connection has been established. It enables the message input box and send button as well as enabling the disconnect button and disabling the connect button. Finally, the message input box is focused so the user can immediately begin to type.
dc.addEventListener("open", ev => {
messageInputBox.disabled = false;
sendMessageButton.disabled = false;
disconnectButton.disabled = false;
connectButton.disabled = true;
messageInputBox.focus();
}, false);
This can also be done by directly setting the value of the channel's
onopen
event handler property.
dc.onopen = ev => {
messageInputBox.disabled = false;
sendMessageButton.disabled = false;
disconnectButton.disabled = false;
connectButton.disabled = true;
messageInputBox.focus();
}
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
open
event
|
Chrome 56 | Edge ≤79 | Firefox Yes | IE No | Opera 43 | Safari Yes | WebView Android 56 | Chrome Android 56 | Firefox Android Yes | Opera Android 43 | Safari iOS Yes | Samsung Internet Android 6.0 |
完整支持
不支持
message
,
close
,和
error
RTCDataChannel
MediaDevices.getUserMedia()
Navigator.mediaDevices
RTCCertificate
RTCDTMFSender
RTCDTMFToneChangeEvent
RTCDataChannelEvent
RTCDtlsTransport
RTCErrorEvent
RTCIceCandidate
RTCIceTransport
RTCPeerConnection
RTCPeerConnectionIceErrorEvent
RTCPeerConnectionIceEvent
RTCRtpReceiver
RTCRtpSender
RTCRtpTransceiver
RTCSctpTransport
RTCSessionDescription
RTCStatsEvent
RTCStatsReport
RTCTrackEvent