daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jun 21st, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <title></title>
  5. </head>
  6. <body>
  7. <pre id="chatter"></pre>
  8. <script type="text/javascript" charset="utf-8">
  9.   const ws = new WebSocket('ws://localhost:3000')
  10.  
  11.   ws.onmessage = ({ data }) => {
  12.     chatter.innerHTML += '\nreceived: ' + data
  13.     setTimeout(() => {
  14.       chatter.innerHTML +=  '\nsending : got it'
  15.       ws.send('got it')
  16.     }, 1000)
  17.   }
  18. </script>
  19. </body>
  20. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top