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

Jabber Presence Data

rmoreton1
Beginner
Beginner

Can I retrieve timecard data on how long a Jabber profile is holding a certain presence status.

I want more granularity than just the Red Yellow Green presence.

I want to see how long a user has been in a particular status like "On a call" or has a custom status.

3 Replies 3

smupadhy
Cisco Employee
Cisco Employee

Hi Robert,

On researching this it appears that CUP and IM & Presence do not provide that information. Even in the XMPP specification, there's no indication that duration of a presence status is ever returned. 

In which case, the duration can only be determined by observing when the status changes, and implies that application is continuously watching/tracking the user's presence.

Thanks,

Smita Upadhya

Thanks Smita,

Is the instantaneous presence status returned on one of the servers?

If I did have a presence watcher/recorder app, where and how could I gather this information?

Best,

Robert Moreton

Hi Robert,

There are a number of ways to gather presence information.  There's a good example that comes with the CAXL SDK called presencequickcontactsexample.html.  Here's a snippet from that example, which handles presence and updates to the presence status.  It binds the "entityCreated" event, which you can use to calculate the start time of a presence status.  It binds the "primaryPresenceChanged" event to a function, which is called when the presence changes for a subscribed contact (you have to subscribe first).

What you'd have to do in order to poll the presence is to note the presence when "entityCreated" is triggered, and save that time.  You only do this once, when you first subscribe to that contact.

Then when you want to poll the presence use contact.getPrimaryPresence(); for that subscribed contact, and calculate how long it has remained at that presence.  When the presence changes, it will trigger the "primaryPresenceChanged" event, and you reset the time.

Note that the example is for quick contacts (contacts you define on the fly, not from your roster), but the principle is the same, and you can apply it to roster contacts, too.

Does that answer your questions?

                /**

                * Here we bind the 'entityCreated' event on the EntitySet.

                * This event is triggered when subscribing to a JID(s).

                * The event is passed the jabberwerx.Entity that was created

                * and is retrieved from the event data.

                *

                * The 'primaryPresenceChanged' event is bound on

                * the entity to track any changes in presence. This event is

                * triggered when the presence of a enitiy changes and is passed

                * a jabberwerx.Presence object if connected,  null if the

                * entity goes offline.

                */

               client.entitySet.event("entityCreated").bind(function(evt) {

                   var qcontact = evt.data;

                   _roster._updateRosterItem(qcontact);

                   qcontact.event("primaryPresenceChanged").bind(function(evt) {

                       _roster._updateRosterItem(qcontact);

                    });

               });

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: