Search code examples
javascriptxmppcross-platformngcordovastrophe

How to get the list of all rooms in openfire server


Can someone please guide me on how to retrieve the list of all available rooms in openfire using strophe.js. I did not find anything really usefull related to this topic. Thanks


Solution

  • I spent few hours to find a solution, but it was easier than expected. I will add this part of code, so may be someone will need it in a future.

            getListRooms = function(server){
            var iq;
            iq = $iq({
              to: server,
              from: connection.jid,
              type: "get"
            }).c("query", {
              xmlns: Strophe.NS.DISCO_ITEMS
            });
          connection.sendIQ(iq.tree(), function (iq) {
            console.log(iq);
            if (!iq || iq.length == 0)
                return;
            //jquery load data after loading the page.This function updates data after jQuery loading
            $rootScope.$apply(function () {
    
                $(iq).find("item").each(function () {
    //your function to update
     });
            });
            console.log('success, all rooms received'); }, function (err) { console.log('error, something went wrong with rooms receivig', err); });
        }