Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <body>
  2. <script>
  3. var Socket = new WebSocket("ws://localhost:778");
  4.  
  5. Socket.onopen = function() {
  6. alert("Connection established");
  7. };
  8. Socket.onclose = function(event) {
  9. if (event.wasClean) {
  10. alert('Connection closed clean');
  11. }
  12. else {
  13. alert('Connection aborted'); // например, "убит" процесс сервера
  14. }
  15. alert('Code ' + event.code + ' Reason ' + event.reason);
  16. };
  17.  
  18. Socket.onmessage = function(event) {
  19. alert("Data received " + event.data);
  20. };
  21.  
  22. Socket.onerror = function(error) {
  23. alert("Error " + error.message);
  24. };
  25. </script>
  26. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement