I'm trying to send text over an RTCPeerConnection
with RTCDataChannel
using WebRTC's adapter.js, but I'm getting the following error:
Uncaught InvalidStateError:
Failed to execute 'send' on 'RTCDataChannel':
RTCDataChannel.readyState is not 'open'
My code is available via this fiddle and below:
var peerConnection = new RTCPeerConnection(null, {
optional: [{
RtpDataChannels: true
}]
});
peerConnection.ondatachannel = function(event) {
receiveChannel = event.channel;
receiveChannel.onmessage = function(event){
alert(event.data);
};
};
var dataChannel = peerConnection.createDataChannel("data", {reliable: false});
dataChannel.send("Hello");
Am I doing anything wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…