Advertisement
Guest User

PeerJS test

a guest
May 21st, 2020
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4.  
  5. <meta charset="utf-8">
  6. <title>Test</title>
  7.  
  8. </head>
  9.  
  10. <body></body>
  11.  
  12. <script src="librairie/peerjs.js"></script>
  13.  
  14. <script >
  15.  
  16. var peer = new Peer();
  17.  
  18. var conn = peer.connect('addsdfdsfgdfqgdfshsdffhsfghsdfhdfgsfddhtrhzhrtgjsd');
  19.  
  20. conn.on('open', function(){
  21.  
  22. conn.send('hi!');
  23.  
  24. });
  25.  
  26. peer.on('connection', function(conn) {
  27.  
  28. console.log("Connection");
  29.  
  30. conn.on('data', function(data){
  31.  
  32. console.log("Data: ");
  33. console.log(data);
  34.  
  35. });
  36.  
  37. });
  38.  
  39. </script>
  40.  
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement