cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
991
Views
0
Helpful
2
Replies

Get people list according to status

mathis941
Level 1
Level 1

Hello,

Is there any way using Jabber sdk/api to search all people who has a specific presence.

For example the list of all people who have the "away" custom status "eating"

Thank you

2 Replies 2

npetrele
Cisco Employee
Cisco Employee

Try something like this (the groups part probably isn't necessary - you can try to remove it):

var groups = this.client.entitySet.getAllGroups();
var arrayLength = groups.length;
for (i = 0; i < arrayLength; i++) {
     var thisGroup = groups[i];
     this.client.entitySet.each(function(entity) {
          if (entity instanceof jabberwerx.RosterContact && ($.inArray(thisGroup, groups) != -1)) {
               try {
                    presence = entity.getPrimaryPresence();
                    if (presence != null) {
                         var show = presence.getType() || presence.getShow() || "available";
                         var status = presence.getStatus();
                         var priority = presence.getPriority();
                         switch (show) {
                              case "available":
                                   break;
                              case "away":
                                   break;
                              case "xa":
                                   break;
                              default:
                                   break;
                         }
                    }
               } catch (ex) {
                    log("JWA", "execption in presence " + ex);
               }
          }
     });
}

Thank you Nicholas, it looks promising

What SDK this script use ?

Can it be integrated on a non web-based jabber? (at my work we use Cisco Jabber software)

Thanks again !