Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="de">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Titel</title>
- </head>
- <body>
- </body>
- <script>
- var ws = new WebSocket('wss://echo.websocket.org');
- ws.onopen = () => {
- // connection opened
- ws.send('something'); // send a message
- };
- ws.onmessage = (e) => {
- // a message was received
- console.log(e.data);
- };
- ws.onerror = (e) => {
- // an error occurred
- console.log(e.message);
- };
- ws.onclose = (e) => {
- // connection closed
- console.log(e.code, e.reason);
- };
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement