I am currently testing and working on the webrtc firebase demo by Muaz khan. In one of the files it uses Xirsys and the credentials used are the ones of Muaz Khan. The xirsys details are of version v2. Currently Xirsys uses version V3. I was wondering how to change the former code to the new code.
The former code which is working in the demo is
<script type="text/javascript" src="https://gc.kis.v2.scr.kaspersky-
labs.com/EC7AD6FB-B1E9-9D47-B085-7DB58B77DF98/main.js" charset="UTF-8">
</script><script>
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
var url = 'https://service.xirsys.com/ice';
var xhr = createCORSRequest('POST', url);
xhr.onload = function () {
window.parent.postMessage({
iceServers: JSON.parse(xhr.responseText).d.iceServers
}, '*');
};
xhr.onerror = function () {
console.error('Woops, there was an error making xhr request.');
};
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
window.addEventListener('message', function (event) {
if (!event.data || typeof event.data !== 'string') return;
if(event.data == 'get-ice-servers') {
xhr.send('ident=muazkh&secret=59d93f26-5b89-11e5-babe-
d61aeb366a63&domain=webrtcexperiment-webrtc.netdna-
ssl.com&application=default&room=default&secure=1');
}
});
</script>
According to the new Xirsys documentation it should be like
<!-- JS Get ICE STUN and TURN list -->
<DOCTYPE>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js">
</script>
<script>
$( document ).ready( function () {
$.ajax ({
url: "https://global.xirsys.net/_turn/muazkh/",
type: "PUT",
async: false,
headers: {
"Authorization": "Basic " + btoa("muazkh:59d93f26-5b89-11e5-babe-d61aeb366a63")
},
success: function (res){
console.log("ICE List: "+res.v.iceServers);
}
});
})
</script>
</head>
<body>
</body>
</html>
What I did was this but did not work
<head><script>
function createCORSRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
var url = 'https://global.xirsys.net/_turn/muazkh/default/default';
var xhr = createCORSRequest('PUT', url);
xhr.onload = function () {
window.parent.postMessage({
iceServers: JSON.parse(xhr.responseText).v.iceServers
}, '*');
};
xhr.onerror = function () {
console.error('Woops, there was an error making xhr request.');
};
xhr.setRequestHeader("Authorization", "muazkh:59d93f26-5b89-11e5-babe-d61aeb366a63");
window.addEventListener('message', function (event) {
if (!event.data || typeof event.data !== 'string') return;
if(event.data == 'get-ice-servers') {
xhr.send();
}
});
</script>
</head>
Will greatly appreciate any help here. Thanks