Created
October 12, 2021 00:59
-
-
Save SaurabhKharivale/266d7d4536956a9161c0121061c2cecf to your computer and use it in GitHub Desktop.
webrtc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iceConfiguration = { } | |
iceConfiguration.iceServers = []; | |
//turn server | |
iceConfiguration.iceServers.push({ | |
urls: 'turn:numb.viagenie.ca', | |
credential: 'muazkh', | |
username: 'webrtc@live.com' | |
}) | |
iceConfiguration.iceServers.push({ | |
urls: 'turn:192.158.29.39:3478?transport=udp', | |
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', | |
username: '28224511:1379330808' | |
}) | |
iceConfiguration.iceServers.push({ | |
urls: 'turn:192.158.29.39:3478?transport=tcp', | |
credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', | |
username: '28224511:1379330808' | |
}) | |
//stun server | |
iceConfiguration.iceServers.push({ urls: 'stun:stun1.l.google.com:19302' }) | |
iceConfiguration.iceServers.push({ urls: 'stun:stun2.l.google.com:19302' }) | |
iceConfiguration.iceServers.push({ urls: 'stun:stun3.l.google.com:19302' }) | |
iceConfiguration.iceServers.push({ urls: 'stun:stun4.l.google.com:19302' }) | |
iceConfiguration.iceServers.push({ urls: 'stun:stun01.sipphone.com' }) | |
iceConfiguration.iceServers.push({ urls: 'stun:stunserver.org' }) | |
const localConnection = new RTCPeerConnection(iceConfiguration) | |
localConnection.onicecandidate = e => { | |
console.log(" NEW ice candidnat!! on localconnection reprinting SDP " ) | |
console.log(JSON.stringify(localConnection.localDescription)) | |
} | |
const sendChannel = localConnection.createDataChannel("sendChannel"); | |
sendChannel.onmessage =e => console.log("messsage received!!!" + e.data ) | |
sendChannel.onopen = e => console.log("open!!!!"); | |
sendChannel.onclose =e => console.log("closed!!!!!!"); | |
localConnection.createOffer().then(o => localConnection.setLocalDescription(o) ) | |
//this opens the connection | |
localConnection.setRemoteDescription (answer).then(a=>console.log("done")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment