Commit 5e08e43e by Dw9 Committed by GitHub

webrtc测试网页新增datachannel echo显示框 (#1613)

parent 5844b618
...@@ -64,8 +64,12 @@ ...@@ -64,8 +64,12 @@
<button onclick="stop()">停止(stop)</button> <button onclick="stop()">停止(stop)</button>
<p> <p>
<label for="msg">msg:</label> <label for="msgsend">msgsend:</label>
<input type="text" id='msg' value="hello word !"> <input type="text" id='msgsend' value="hello word !">
</p>
<p>
<label for="msgrecv">msgrecv:</label>
<input type="text" id='msgrecv' disabled>
</p> </p>
<button onclick="send()">发送(send by datachannel)</button> <button onclick="send()">发送(send by datachannel)</button>
<button onclick="close()">关闭(close datachannel)</button> <button onclick="close()">关闭(close datachannel)</button>
...@@ -185,6 +189,7 @@ ...@@ -185,6 +189,7 @@
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_MSG,function(event) player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_MSG,function(event)
{ {
console.log('rtc datachannel 消息 :',event.data) console.log('rtc datachannel 消息 :',event.data)
document.getElementById('msgrecv').value = event.data
}); });
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_ERR,function(event) player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_ERR,function(event)
{ {
...@@ -237,7 +242,7 @@ ...@@ -237,7 +242,7 @@
function send(){ function send(){
if(player){ if(player){
//send msg refernece https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/send //send msg refernece https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/send
player.sendMsg(document.getElementById('msg').value) player.sendMsg(document.getElementById('msgsend').value)
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论