stompjs-proxy
Version:
Stomp websocket proxy, for Stomp.js
36 lines (28 loc) • 647 B
JavaScript
var Stomp = require('stompjs');
(function doemit() {
var client = Stomp.overTCP('127.0.0.1', 61613, {
onerror: onend,
onclose: onend,
});
var timer = setTimeout(function () {
client.disconnect();
onend();
}, 5*1000);
client.debug = console.log.bind(console);
client.connect({}, function onopen() {
clearTimeout(timer);
(function snd() {
if (client) {
client.send('/topic/foo', {}, 'Hello, Stomp!');
setTimeout(snd, 1000);
}
})();
});
function onend(e) {
if (e) console.log(e);
if (client) {
client = null;
setTimeout(doemit, 1000);
}
}
})();