At the moment, I am playing around with WebRTC. My goal is to setup a datachannel between two browsers. Chrome-Chrome is working well. Now I am playing with Firefox-Firefox. Here is a MEW from my current code:
var servers = { "iceServers": [{ "url": "stun:stun.l.google.com:19302" }] };
var RTCPeerConnection = window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var SessionDescription = window.mozRTCSessionDescription || window.RTCSessionDescription;
var IceCandidate = window.mozRTCIceCandidate || window.RTCIceCandidate;
var peerConnection = new RTCPeerConnection(servers, { optional: [{ RtpDataChannels: true }] });
peerConnection.onicecandidate = function (event) {
peerConnection.onicecandidate = null;
console.log('ICE Candidate:', JSON.stringify(event.candidate))
};
var channel = peerConnection.createDataChannel("sendDataChannel", {reliable: false});
peerConnection.createOffer(
function (offer) {
peerConnection.setLocalDescription(offer);
}, function (e) { }
);
As soon setLocalDescription
is called, the function onicecandidate
is called (as expected). In Chrome 36 the event.icecandidate
is something like:
{"sdpMLineIndex":0,"sdpMid":"audio","candidate":"a=candidate:3430859439 1 udp 2122260223 xxx.xxx.xxx.xxx 59773 typ host generation 0\r\n"}
In Firefox the event.icecandidate
is just null
. But I need to send that ICE candidate over the signaling channel to establish the connection.