Skip to content

Instantly share code, notes, and snippets.

@balamuru
Created April 2, 2014 06:00
Show Gist options
  • Save balamuru/9928677 to your computer and use it in GitHub Desktop.
Save balamuru/9928677 to your computer and use it in GitHub Desktop.
<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