RTCDataChannel.onopen - Web APIs 编辑
Experimental
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The RTCDataChannel.onopen
property is an EventHandler
which specifies a function to be called when the open
event is fired; this is a simple Event
which is sent when the data channel's underlying data transport—the link over which the RTCDataChannel
's messages flow—is established or re-established.
Syntax
RTCDataChannel.onopen = function;
Value
A function which the browser will call to handle the open
event. The function receives as its only input parameter the event itself, of type Event
.
Example
This example adds a new data channel to an existing RTCPeerConnection
, myPeerConnection
. It then establishes an open
event handler which updates some user interface elements to prepare them for being used to send messages over the data channel.
let dc = myPeerConnection.createDataChannel("Message Channel");
dc.onopen = function(event) {
let messageBox = document.getElementById("messageBox");
let sendButton = document.getElementById("sendButton");
messageBox.disabled = false;
messageBox.focus();
sendButton.disabled = false;
}
Specifications
Specification | Status | Comment |
---|---|---|
WebRTC 1.0: Real-time Communication Between Browsers The definition of 'RTCDataChannel.onopen' in that specification. | Candidate Recommendation | Initial specification. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论