06-21-2017 01:56 PM
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
06-22-2017 08:44 AM
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.
06-22-2017 08:50 AM
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.
06-22-2017 10:02 AM
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();
}
}
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: