我在WebRtc
使用 javascript 集成视频和聊天时遇到问题。我正在使用这个例子
https://github.com/oney/react-native-webrtc-server/blob/master/index.html
视频工作正常,但发送消息失败也没有接收错误!!!!。作为上述示例中共享的数据通道,这些功能:
Line #115 to 142 of above link
if (pc.textDataChannel) {
return;
}
var dataChannel = pc.createDataChannel("text");
dataChannel.onerror = function (error) {
};
dataChannel.onmessage = function (event) {
console.log('open state2')
var content = document.getElementById('textRoomContent');
content.innerHTML = content.innerHTML + '<p>' + socketId + ': ' + event.data + '</p>';
};
dataChannel.send = function (event) {
console.log('open state2')
exchange(event)
};
dataChannel.onopen = function () {
console.log('open state')
var textRoom = document.getElementById('textRoom');
textRoom.style.display = "block";
};
dataChannel.onclose = function () {
};
pc.textDataChannel = dataChannel;
在发送消息时它的用途:
pc.textDataChannel.send(text);//Line #218 of above link
我到底应该实现什么才能起作用我认为这个发送没什么,这就是为什么消息失败和视频工作