03-19-2014 07:53 AM
We are working on customizing IM/Presence for a user.
03-19-2014 02:51 PM
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
05-10-2014 02:43 PM
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?
05-14-2014 09:02 AM
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
05-14-2014 05:57 PM
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/
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide