Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.mySocket.onmessage = function(event){
- var signal = JSON.parse(event.data);
- if (signal.sdp) {
- if(init){
- log('received offer...');
- pc.setRemoteDescription(new RTCSessionDescription(signal))
- .then(function(){
- pc.createAnswer()
- .then(function(answer) {
- log('created answer...');
- return pc.setLocalDescription(answer);
- })
- .then(function() {
- log('sent answer');
- window.mySocket.send(JSON.stringify(pc.localDescription));
- })
- .catch(function(reason) {
- log(reason)
- });
- })
- .catch(function(reason) {
- log(reason)
- });
- }else{
- log('received offer...');
- pc.setRemoteDescription(signal)
- }
- }else if(signal.candidate){
- pc.addIceCandidate(new RTCIceCandidate(signal));
- }
- }
Add Comment
Please, Sign In to add comment