Skip to content

Instantly share code, notes, and snippets.

@LinuxDoku
Created October 30, 2011 18:58
Show Gist options
  • Save LinuxDoku/1326279 to your computer and use it in GitHub Desktop.
Save LinuxDoku/1326279 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>RG Test</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
// web socket test
var socket = new WebSocket("ws://localhost:1414/sockettest/server.php");
socket.onopen = function(event) {
$('#response').html($('#response').html()+"\n Connect to server...");
};
socket.onerror = function(event) {
$('#response').html($('#response').html()+"\n An error occoured: "+event.data);
};
socket.onmessage = function(event) {
$('#response').html($('#response').html()+"\n Message: "+event.data);
};
socket.onclose = function(event) {
$('#response').html($('#response').html()+"\n Close: "+event.data);
};
</script>
</head>
<body>
<div id="response">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment