Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <body>
  2. <script>
  3. channel = new goog.appengine.Channel('{{ token }}');
  4. socket = channel.open();
  5. socket.onopen = onOpened;
  6. socket.onmessage = onMessage;
  7. socket.onerror = onError;
  8. socket.onclose = onClose;
  9.  
  10. function onMessage (signal) {
  11. console.log('On message ' + signal)
  12.  
  13. var msg = JSON.parse(signal.data);
  14. if (msg.type == "offer") {
  15. pc.setRemoteDescription(new RTCSessionDescription(msg.data));
  16. pc.createAnswer(gotAnswer);
  17. } else if (msg.type == "answer") {
  18. pc.setRemoteDescription(new RTCSessionDescription(msg.data));
  19. } else if(msg.type == "candidate") { // Candidate
  20. pc.addIceCandidate(new RTCIceCandidate(msg.data));
  21. }
  22. };
  23. </script>
  24. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement