Sha256: 811f1170e4d0e8d4d216f0a5213556e7d81ccc843c9991647ee8a717cb26a058
Contents?: true
Size: 881 Bytes
Versions: 14
Compression:
Stored size: 881 Bytes
Contents
<!doctype html> <html lang="en"> <head> <title>Websocket Client</title> </head> <body> <script> var connect = function () { var exampleSocket = new WebSocket("ws://localhost:4411/"); exampleSocket.onopen = function (event) { document.querySelector('#status').innerText = 'connected'; exampleSocket.send("Can you hear me?"); }; exampleSocket.onclose = function (event) { document.querySelector('#status').innerText = 'disconnected'; setTimeout(function () { // exampleSocket.removeAllListeners(); connect(); }, 1000); } exampleSocket.onmessage = function (event) { document.querySelector('#msg').innerText = event.data; console.log(event.data); } }; connect(); </script> <h1 id="status">disconnected</h1> <h1 id="msg"></h1> </body> </html>
Version data entries
14 entries across 14 versions & 1 rubygems