Skip to content

Instantly share code, notes, and snippets.

@den385
Created April 30, 2018 16:10
Show Gist options
  • Save den385/3b9e79b2825f931801ca4fde8a96f6dc to your computer and use it in GitHub Desktop.
Save den385/3b9e79b2825f931801ca4fde8a96f6dc to your computer and use it in GitHub Desktop.
function WebSocketTest()
{
if ("WebSocket" in window)
{
var ws = new WebSocket("ws://localhost:9990/ws?param=valu&another_param=another_value");
ws.onmessage = function(evt)
{
var msg = evt.data;
var div = document.createElement('div');
div.textContent = msg;
document.body.appendChild(div);
};
}
else
{
alert("This browser does not support WebSockets.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment