Advertisement
Guest User

Untitled

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