cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
687
Views
0
Helpful
1
Replies

Trying to subscribe to pubsub queues notifications

armandoramirez
Level 1
Level 1

I followed the sample code from the Non Gadget and I can get user notifications and dialog notification but no queues info.

This is the code I have, I put the sendIq function inside the successCallback

I just want to subscribe to realtime queue changes.  Thank you

   var _username = "1041";

   var _domain = "SERVER.com";

   var _password = "password";

function _eventConnect() {

    if (window.jabberwerx) {

        //alert("connecting");

        //Construct JID with username and domain.

        jid = _username + "@" + _domain,

        //Create JabbwerWerx object.

        _jwClient = new jabberwerx.Client("resource");

        //Arguments to feed into the JabberWerx client on creation.

  jwArgs = {

            //Defines the BOSH path. Should match the path pattern in the proxy

            //so that it knows where to forward the BOSH request to.

            httpBindingURL: "https://SERVER.com:7443/http-bind/",

            //Calls this function callback on successful BOSH connection by the

            //JabberWerx library.

  errorCallback: onClientError,

            successCallback: function () {

                //Get the server generated resource ID to be used for subscriptions.

                _finesse.setResource(_jwClient.resourceName);

  _jwClient.sendIq('set', "pubsub.SERVER.com", "<pubsub xmlns='http://jabber.org/protocol/pubsub'><subscribe node='/finesse/api/Queue/3' jid='1041@SERVER.com' /></pubsub>", function(data){

  alert("success");

  console.info(data);

  });

            }

        };

       

        jabberwerx._config.unsecureAllowed = true;

        //Bind invoker function to any events that is received. Only invoke

        //handler if XMPP message is in the specified structure.

        _jwClient.event("messageReceived").bindWhen(

                "event[xmlns='http://jabber.org/protocol/pubsub#event'] items item notification",

                _eventHandler);

  _jwClient.event("clientStatusChanged").bind(function(evt) {

  });

        //Connect to BOSH connection.

        _jwClient.connect(jid, _password, jwArgs);

    } else {

        alert("CAXL library not found. Please download from http://developer.cisco.com/web/xmpp/resources")

    }

}

1 Accepted Solution

Accepted Solutions

armandoramirez
Level 1
Level 1

Nevermind, I just had to move the sendIq function to be executed first on the successCallback.

            successCallback: function () {

                //Get the server generated resource ID to be used for subscriptions.

                 _jwClient.sendIq('set', "pubsub.SERVER.com", "<pubsub xmlns='http://jabber.org/protocol/pubsub'><subscribe node='/finesse/api/Queue/3' jid='1041@SERVER.com' /></pubsub>", function(data){

                      alert("success");

                      console.info(data);

                 });

                _finesse.setResource(_jwClient.resourceName);

            }

It is working now.

View solution in original post

1 Reply 1

armandoramirez
Level 1
Level 1

Nevermind, I just had to move the sendIq function to be executed first on the successCallback.

            successCallback: function () {

                //Get the server generated resource ID to be used for subscriptions.

                 _jwClient.sendIq('set', "pubsub.SERVER.com", "<pubsub xmlns='http://jabber.org/protocol/pubsub'><subscribe node='/finesse/api/Queue/3' jid='1041@SERVER.com' /></pubsub>", function(data){

                      alert("success");

                      console.info(data);

                 });

                _finesse.setResource(_jwClient.resourceName);

            }

It is working now.