cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3285
Views
0
Helpful
4
Replies

How to get the presence of a valid jabber user using CAXL API

ashish_rai
Level 1
Level 1

We are working on customizing IM/Presence for a user.

  • Which classes/method of CAXL API provides us the presence of a user who has logged in.
  • Presence of other users who are on the public pages(Blog,Discussion).
4 Replies 4

tinghche
Level 5
Level 5

For the user that is on your roster, you can do the following.

var myentity = jabberwerx.RosterContact;

if(myentity.identities == "") {

  rosterpresence = myentity.getPrimaryPresence();

  if (rosterpresence) {

  show = rosterpresence.getType() ||

  rosterpresence.getShow() ||

  "available";

  status = rosterpresence.getStatus();

  }

  show = " [" + show + "]" + (status ? "(" + status + ")" : "");

  $("#mycontacts").append(myentity.getDisplayName()+":"+myentity.getGroups()+"<br/>");

  }

For the user that are not in your roster, you can use QuickContactController to temporary subscribe their jid, then you should be able to get their presence status.

However, by doing this you have to know their user id to be able to subscribe to the correct jid. There is no Jabber search implemented in CAXL yet, hence you can't search a person using XEP-0055

var qcController = new jabberwerx.cisco.QuickContactController(client);

Thanks,

Howard

Looking at the API for QuickContactController I do not see any methods that would tell me what the clients current status is.

Is there a sample code file I can see that takes a user id and uses CAXL to obtain their current status?

John,

You will have to use subscribe function to do so.

First create a quick contact controller

var qcController = new jabberwerx.cisco.QuickContactController(client);

Then, subscribe a jid to that controller

qcController.subscribe(jid+'@'+demo_config.domain);

You can loop through the entity to get the user id and status.

Or, bind the event of "entityCreated" or "primaryPresenceChanged" to listen to the status changes as well.

Regards,

Howard

This is the code that I am running but I get an error on the client.event that tells me: “Uncaught TypeError: Cannot read property ‘bind’ of undefined

clientcode = 'chat' + Math.floor((Math.random() * 10000) + 1);

client = new jabberwerx.Client(clientcode);

qcController = new jabberwerx.cisco.QuickContactController(client);

client.event("primaryPresenceChanged").bind(function(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();

});

I found a help document that advised how to use the entityset, so I got rid of the bind above and added this after I subscribed the user. I found that the jid was stored in lowercase and I could get the entity if I converted the jid to lowercase.

contact = client.entitySet.entity(lval.toLowerCase());

var primarypresence = contact.getPrimaryPresence();

var status = primarypresence.getStatus();

I am able to get a presence object back from getPrimaryPresence, but the getStatus returns null.

Can you advise how I can properly use quickcontactcontroller and/or advise on how to correct this code?

-john mennear

408-894-6856

http://cisco-ucdt.blogspot.com/

http://cisco-ciac.blogspot.com/