a zip code crypto-currency system good for red ONLY

ws.html 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>WebSocket test</title>
  6. </head>
  7. <body>
  8. <h1>WebSocket test</h1>
  9. <ul></ul>
  10. <script type="text/javascript">
  11. var logger = document.getElementsByTagName('ul')[0],
  12. Socket = window.MozWebSocket || window.WebSocket,
  13. protos = ['foo', 'bar', 'xmpp'],
  14. socket = new Socket('ws://' + location.hostname + ':' + location.port + '/', protos),
  15. index = 0;
  16. var log = function(text) {
  17. logger.innerHTML += '<li>' + text + '</li>';
  18. };
  19. socket.addEventListener('open', function() {
  20. log('OPEN: ' + socket.protocol);
  21. socket.send('Hello, world');
  22. });
  23. socket.onerror = function(event) {
  24. log('ERROR: ' + event.message);
  25. };
  26. socket.onmessage = function(event) {
  27. log('MESSAGE: ' + event.data);
  28. setTimeout(function() { socket.send(++index + ' ' + event.data) }, 2000);
  29. };
  30. socket.onclose = function(event) {
  31. log('CLOSE: ' + event.code + ', ' + event.reason);
  32. };
  33. </script>
  34. </body>
  35. </html>