Created
December 4, 2017 00:17
-
-
Save AndyNovo/2e5a58478b2b1640710170fdba1ac617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>WebSocket Test</title> | |
</head> | |
<body> | |
<ul id="msgs"> | |
</ul> | |
<script> | |
var ws; | |
window.onload=function(){ | |
ws=new WebSocket("wss://SPACENAME-USERNAME.c9users.io:8081"); | |
ws.onmessage=function(evt){ document.querySelector("#msgs").innerHTML += `<li>${evt.data}</li>`;}; | |
ws.onopen=function(evt){ | |
ws.send("Hello"); | |
} | |
} | |
window.onclose=function(){ | |
ws.close(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment