Created
April 2, 2014 06:00
-
-
Save balamuru/9928677 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
<script src="stomp.js"></script> | |
<script type="text/javascript"> | |
var myTopic = "/topic/greetings"; | |
var client = Stomp.client("ws://localhost:61614/stomp", "v11.stomp"); | |
console.log("start"); | |
client.connect("", "", | |
function () { | |
client.subscribe(myTopic, | |
function (message) { | |
console.log("Ok....got the message jack!"); | |
printMsg(message); | |
printMsg("Body:"+message.body); | |
printMsg("---------------------"); | |
}, | |
{ priority: 9 } | |
); | |
} | |
); | |
function sendIt() { | |
console.log("send it"); | |
client.send(myTopic, { priority: 9 }, "Test Pub/Sub Message"); | |
} | |
function printMsg(message) { | |
var response = document.getElementById('response'); | |
var p = document.createElement('p'); | |
p.style.wordWrap = 'break-word'; | |
p.appendChild(document.createTextNode(message)); | |
response.appendChild(p); | |
} | |
</script> | |
<html> | |
<body> | |
<br> | |
<input type="button" value="Test message" onclick="sendIt();"> | |
<h1>Log</h1> | |
<p id="response"></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment