Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <pre id="chatter"></pre>
- <script type="text/javascript" charset="utf-8">
- const ws = new WebSocket('ws://localhost:3000')
- ws.onmessage = ({ data }) => {
- chatter.innerHTML += '\nreceived: ' + data
- setTimeout(() => {
- chatter.innerHTML += '\nsending : got it'
- ws.send('got it')
- }, 1000)
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment