const peer = new Peer('receiver', { host: '10.1.1.99', port: 9000, path: '/', debug: 3 })
// var debugElement = domcument.getElementById('debug');
peer.on('call', function (call) {
var conf = confirm('Some one is calling you...')
if (conf) {
navigator.mediaDevices.getUserMedia({
video: true
}).then(function (localStream) {
document.getElementById('local').srcObject = localStream;
call.answer(localStream);
call.on('stream', function (remoteStream) {
document.getElementById('remote').srcObject = remoteStream;
});
}).catch(function (error) { console.log(error); });
}
});
peer.on('error', function (err) {
var node = document.createElement("LI"); // Create a <li> node
var textnode = document.createTextNode(err); // Create a text node
node.appendChild(textnode); // Append the text to <li>
document.getElementById("debug").appendChild(node); // Append <li> to <ul> with id="myList"
});