p2pchat.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <html>
  2. <head>
  3. <link href="http://peerjs.com/css/style.css" rel="stylesheet" type="text/css">
  4. <link href="http://peerjs.com/css/fonts.css" rel="stylesheet" type="text/css">
  5. <link href="http://peerjs.com/css/button.css" rel="stylesheet" type="text/css">
  6. <link href="http://peerjs.com/css/reveal.css" rel="stylesheet" type="text/css">
  7. <style>
  8. html,body{margin:0px;padding:0px;background:#efefef;}
  9. #wrapper{padding:30px;width:600px;margin:0 auto;text-align: center;}
  10. #stage
  11. {
  12. display:none;
  13. text-align:left;
  14. background:#fff;
  15. overflow-y:auto;
  16. }
  17. #submitbar
  18. {
  19. border:solid 1px #ddd;
  20. }
  21. #submitbar input[type=text]
  22. {
  23. width:530px;
  24. }
  25. #chatlog
  26. {
  27. height:550px;
  28. padding:10px;
  29. }
  30. #enter{
  31. padding:20px;
  32. border-radius: 15px;
  33. background:#ddd;
  34. }
  35. </style>
  36. <title>P2P Web Chat with PeerJS</title>
  37. </head>
  38. <body>
  39. <div id="wrapper">
  40. <h1>P2P Web Chat with PeerJS</h1>
  41. <div id="enter">
  42. <div class="step1">
  43. <input id="i_username" type="text" placeholder="Username"/> <input id="connectbtn" type="button" class="btn btn-danger" value="Set Username"/>
  44. </div>
  45. <div class="step2" style="display:none;">
  46. <h2>Waiting for Friend to connect...</h2>
  47. <h3>---<br/>OR connect to a Friend:</h3>
  48. <input id="i_peer" type="text" placeholder="Friend's Username"/> <input id="peerbtn" type="button" class="btn btn-danger" value="Connect"/>
  49. </div>
  50. </div>
  51. <div id="stage">
  52. <div id="chatlog"></div>
  53. <div id="submitbar"><input id="message" type="text"/> <input id="sendbtn" type="button" class="btn btn-danger" value="Send"/></div>
  54. </div>
  55. </div>
  56. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
  57. <script src="file:///C:/node/peers/dist/peer.js" ></script>
  58. <script type="text/javascript">
  59. var peer = new Peer('peer1', {host: 'localhost', port: 9000, debug: true});
  60. peer.on('error',function(error) {
  61. console.log('error', arguments);
  62. });
  63. peer.on('open',function() {
  64. console.log('open!')
  65. });
  66. peer.on('connection', function(){};
  67. });
  68. </script>
  69. </body>
  70. </html>