Skip to content

Instantly share code, notes, and snippets.

@saghul
Created June 28, 2011 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saghul/1051836 to your computer and use it in GitHub Desktop.
Save saghul/1051836 to your computer and use it in GitHub Desktop.
Simple HTML WebSocket client for the ZeroMQ gateway
<html>
<head>
<title>ZWS Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" ></script>
<script language='javascript'>
$(document).ready(function() {
var ws = new WebSocket("ws://localhost:9999/test");
ws.onmessage = function(evt) {
$('#output').append(evt.data+'<br />');
}
ws.onopen = function(evt) {
$('#conn_status').html('<b>Connected</b>');
}
ws.onerror = function(evt) {
$('#conn_status').html('<b>Error</b>');
}
ws.onclose = function(evt) {
$('#conn_status').html('<b>Closed</b>');
}
});
</script>
</head>
<body>
<h1>ZMQ - WebSocket Example</h1>
<div id="conn_status">Not Connected</div>
<div id="output"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment