Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="de">
  4. <head>
  5. <meta charset="utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>Titel</title>
  8. </head>
  9. <body>
  10.  
  11. </body>
  12. <script>
  13.  
  14. var ws = new WebSocket('wss://echo.websocket.org');
  15.  
  16. ws.onopen = () => {
  17. // connection opened
  18. ws.send('something'); // send a message
  19. };
  20.  
  21. ws.onmessage = (e) => {
  22. // a message was received
  23. console.log(e.data);
  24. };
  25.  
  26. ws.onerror = (e) => {
  27. // an error occurred
  28. console.log(e.message);
  29. };
  30.  
  31. ws.onclose = (e) => {
  32. // connection closed
  33. console.log(e.code, e.reason);
  34. };
  35. </script>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement