Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////// CUSTOM SCRIPT BEGIN ////////////////////
- // Connection parameters
- var client; //Variable client must be declared outside connect()
- var mq_username = "guest",
- mq_password = "guest",
- mq_vhost = "/",
- mq_url = 'http://localhost:15674/stomp';
- // This will be called upon successful connection
- function on_connect() {}
- // This will be called upon arrival of a message
- function on_message(m) {}
- // This will be called upon a connection error
- function on_connect_error(error) {
- try {
- client.disconnect(function () {
- $('#debug').append('Disconnected!' + "<br>");
- varmessage = 'Disconnected!' + "<br>";
- });
- $('#debug').append('Reconnecting...' + "<br>");
- varmessage = 'Reconnecting...' + "<br>";
- setTimeout("Connect();", 5000); //Pause 5000ms before reconnecting
- } catch (err) {
- $('#debug').append('Exception:' + err.message + "<br>");
- varmessage = 'Exception:' + err.message + "<br>";
- }
- }
- function Connect() {
- console.log('Connecting...');
- // Connect
- var ws = new SockJS(mq_url);
- client = Stomp.over(ws);
- client.heartbeat.outgoing = 0;
- client.heartbeat.incoming = 0;
- client.debug = function (str) {
- $("#debug").append(str + "<br>");
- varmessage = str;
- };
- client.connect(
- mq_username, mq_password, on_connect, on_connect_error, mq_vhost);
- }
- Connect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement