Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h1>Socket Output</h1>
- <a href="https://pastebin.com/6zNgQRV5">Server Examples</a>
- <div id="output"></div>
- <script>
- const ws = new WebSocket('ws://localhost:4444')
- let output = document.querySelector("#output");
- ws.onopen = () => {
- console.log('ws opened on browser')
- ws.send('hello world')
- }
- ws.onmessage = (message) => {
- console.log(`message received`, message.data)
- output.innerHTML += `${message.data}<br>`;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement