Created
November 12, 2014 13:48
-
-
Save krishnabhargav/ac7a5af593a20ce50b86 to your computer and use it in GitHub Desktop.
simple web socket test client
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 lang="en"> | |
<meta charset="UTF-8"> | |
<script type="text/javascript"> | |
var socket = new WebSocket("ws://localhost:8080/echo"); | |
socket.onopen = function () { | |
console.log("Connected"); | |
socket.send('hello, world!'); | |
}; | |
socket.onmessage = function (event) { | |
console.log('Received data: ' + event.data); | |
socket.close(); | |
}; | |
socket.onclose = function () { | |
console.log('Lost connection!'); | |
}; | |
</script> | |
<title></title> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment