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

This commit is contained in:
Dw9 2022-05-05 16:34:49 +08:00 committed by GitHub
parent 5844b61880
commit 5e08e43e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,8 +64,12 @@
<button onclick="stop()">停止(stop)</button>
<p>
<label for="msg">msg:</label>
<input type="text" id='msg' value="hello word !">
<label for="msgsend">msgsend:</label>
<input type="text" id='msgsend' value="hello word !">
</p>
<p>
<label for="msgrecv">msgrecv:</label>
<input type="text" id='msgrecv' disabled>
</p>
<button onclick="send()">发送(send by datachannel)</button>
<button onclick="close()">关闭(close datachannel)</button>
@ -185,6 +189,7 @@
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_MSG,function(event)
{
console.log('rtc datachannel 消息 :',event.data)
document.getElementById('msgrecv').value = event.data
});
player.on(ZLMRTCClient.Events.WEBRTC_ON_DATA_CHANNEL_ERR,function(event)
{
@ -237,7 +242,7 @@
function send(){
if(player){
//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)
}
}