« Back to APIs

RE: Retrieving presence of other users or contacts

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hello,
 
We are trying to prototype receiving user presence from WebEx Connect (BTS environment). The developer successfully connected to the service and is able to get presence status for the logged-in user. However, the documentation was not clear on how to retrieve presence for other users (contacts) through the Jabberwerx API. It seems that names of the other contacts need to be added to a roster for the test user followed by a subscription to get presence.
 
Can you please help with code snippets or the API functions that can be used for retrieving presence of others / contacts?
 
Thank you

In the CAXL sdk download (http://developer.cisco.com/web/jabber-developer/get-started), there is a doc/examples folder that contains many example pages that use the CAXL libraries.

I believe that the subscriptionsdemo.html file contains the example code that will help with adding contacts to a roster. The sampleclient.html file also contains some example code related to this topic ¿ although it uses the CAXL UI library also.

Hi,

I would like to use jabberwerx.TemporaryEntity(jid, cache), so that I can add a contact to the client.entitySet temporarly and get the presence of the user.
I am able to add the contact using the following code
var jid= 'abc@cisco.com'; //sample jid/string contact is not in my actual list of users. It a new contact for which I just wants its presence status
var entity = client.entitySet.entity(contact);
if(!entity){
entity = new jabberwerx.TemporaryEntity(jid, client.entitySet);
alert("entity.getDisplayName()-->"+entity.getDisplayName());
alert("entity.jid-->"+entity.jid);
alert("entity.properties-->"+entity.properties);
alert("entity.getPrimaryPresence() if-->"+entity.getPrimaryPresence()); //returns null
}
alert("entity.getPrimaryPresence() out-->"+entity.getPrimaryPresence());// returns null
But I am not able to retrieve the presence of this particular contact.
Could you please provide any code snippet that can help me in retrieving the presence of this particular contact. or what kind of event do I need to bind so that I can get the presence of this user.

Thanks
Haji

Hi Haji,
You will need to subscribe to the entities onPresenceChanged events.
1. Global Event Listener after jabberwerx.Client has been connected
---------- Following Developer Guide.html in the package ------------
// The example places the name of the Call Back in quotation marks. Remove the quotation Marks.
 //jabberwerx.globalEvents.bind("presenceReceived", "onPresenceReceived");
// This is the code you should be using.
jabberwerx.globalEvents.bind("presenceReceived", onPresenceReceived);
// callback method for the 'presenceReceived' event
function onPresenceReceived(event) {
    // get the associated jabberwerx.Presence object data
    var presence = event.data;
    var type = presence.getType();
    var show = presence.getShow();
    var status = presence.getStatus();
    var priority = String(presence.getPriority());
    var fromJID = presence.getFromJID();
    var toJID = presence.getToJID();
}
 
Regards,
Shi Jie