cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
588
Views
1
Helpful
3
Replies

Using getPrimaryPresenceForEntity with CAXL

ryan.pierce54
Level 1
Level 1

I'm working on a user lookup feature and would like to provide a one time presence for the returned users (<10 at a time).  I could subscribe to each user as a quick contact and then unsubscribe once a presence has been received how ever the API seems to provide a function that should do what I'm looking for in client.getPrimaryPresenceForEntity(jid)However when I call this function nothing is ever returned.  Does/should this function actually return the specified users presence as a one time request or am I missing the point of this function?

Thanks,

Ryan

3 Replies 3

npetrele
Cisco Employee
Cisco Employee

One thing I would check is to make sure your jid is a string.  Depending on where you got it, you might have to do a jid.toString();

Personally, I don't get presence manually like that.  I bind the presence event like this:

this.client.event("presenceReceived").bind(this.invocation('_updatePresence'));

And then handle it with _updatePresence like this:

        _updatePresence: function(evt) {

            var presence = evt.data;

When you add a quick contact, that should automatically generate a presence event for that contact, so you could capture it with the event.

Thanks Nicholas,

I'm using that method to retrieve presence for a consistent list of users, but was hoping to avoid the hassle of subscribing, getting presence once and unsubscribing.  That sounds like my only option at this point.

You can always use the entity itself to get the primary presence.

Identify the entity you want, and do:

entity.getPrimaryPresence();

You can iterate through the EntitySet and look for quick contacts.  I've never tested for a quick contact, but I assume something like this would work:

client.entitySet.each(function(entity) {

     if (entity instanceof jabberwerx.QuickContact) {

          somevariable = entity.getPrimaryPresence();

     }

}

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: