Created
April 30, 2018 16:10
-
-
Save den385/3b9e79b2825f931801ca4fde8a96f6dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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