Created
July 24, 2009 03:34
-
-
Save tdavis/153824 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<title>Comet Echo!</title> | |
</head> | |
<body> | |
<h1>Comet Echo!</h1> | |
<input type="text" id="message" value="Zoinks!"> <input type="button" value="Echo This!"> | |
<script type="text/javascript" charset="utf-8"> | |
// fix nasty Javascript permission issue | |
document.domain = document.domain; | |
</script> | |
<script src="/static/js/Orbited.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
// set the orbited settings and port | |
Orbited.settings.port = 9000; | |
Orbited.settings.hostname = "127.0.0.1"; | |
//Orbited.settings.streaming = false; | |
TCPSocket = Orbited.TCPSocket; | |
</script> | |
<script src="/static/js/stomp.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(document).ready(function() { | |
stomp = new STOMPClient(); | |
// Assign callback functions ... | |
// Connection opened | |
stomp.onopen = function() { | |
console.log("Connecting..."); | |
}; | |
// Connection closed | |
stomp.onclose = function(c) { | |
console.log("Connection Lost (" + c + ")"); | |
}; | |
// Error | |
stomp.onerror = function(error) { | |
console.log("Error: " + error); | |
}; | |
// Message Error | |
stomp.onerrorframe = function(frame) { | |
console.log("Error: " + frame.body); | |
}; | |
// Connection Established | |
stomp.onconnectedframe = function() { | |
console.log("Connected."); | |
console.log("Subscribing..."); | |
stomp.subscribe("/echo"); | |
console.log("Subscribed."); | |
}; | |
// Message Received | |
stomp.onmessageframe = function(frame) { | |
console.log("Message Received:" + frame.body); | |
}; | |
stomp.connect('127.0.0.1', 61613); | |
$('input[type=button]').click(function(){ | |
$.ajax({ | |
type: 'POST', | |
url: 'http://127.0.0.1/echo/', | |
data: { | |
'message': $('input[type=text]').val() | |
} | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment