peer1.html 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <title>Peer Test</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta http-equiv="Content-Language" content="en-us">
  7. <meta name="description" content="">
  8. <meta name="keywords" content="">
  9. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  10. <script type="text/javascript" src="/peer.js"></script>
  11. <script>
  12. $(document).ready(function() {
  13. $('#connect').click(function() {
  14. var source = $('#source').val();
  15. sink = new Peer({ key: 'r6l1dggn5hebqpvi', host: 'localhost', port: '9000', debug: true });
  16. connection = sink.connect(source, { username: 'michelle_spoof' })
  17. connection.on('data', function(data) {
  18. console.log(data);
  19. connection.send('Hi there!');
  20. });
  21. });
  22. });
  23. </script>
  24. </head>
  25. <body>
  26. This is a P2P peer.
  27. <br><br>
  28. Enter source ID to connect to:
  29. <br><input type="text" id="source"></input>
  30. <button id="connect">Connect</button>
  31. </body>
  32. </html>