D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
vladimir-ivanov
Full window
Github gist
kdb large data
<html> <head> <script src="c.js"></script> </head> <body><title>websocket</title> <form action=""> <input type="button" value="connect" onclick="connect()"> <input type="text" id="x" placeholder="q)"> <input type="submit" value="send" onclick="return send()"> <input type="button" value="close" onclick="ws.close()"> </form> <textarea id="out" rows=25 cols=80></textarea> <script> var ws, out = document.getElementById("out"); function connect() { if ("WebSocket" in window) { ws = new WebSocket("ws://usernamess:pass@localhost:5000/glad?vlad=more"); out.value = "connecting..."; ws.onopen = function (e) { out.value = "connected"; } ws.onclose = function (e) { out.value = "disconnected"; } ws.onmessage = function (e) { console.timeEnd("sendingMessage") //out.value = e.data; } ws.onerror = function (e) { out.value = e.data; } } else alert("WebSockets not supported on your browser."); } function send() { console.time("sendingMessage"); x = document.getElementById("x"); v = x.value; ws.send(v); //out.value = "sent " + v; return false; } </script> </body> </html>