cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
404
Views
0
Helpful
2
Replies

Chat messages echoes

shahhuss
Level 1
Level 1

Hi

   I am sending message to other user using client.sendMesage(toUser,messageContent) , here if toUser is not logged to the cups then in sender side messages are getting echoed , i am trying to validate toUser status if its connected or not using the api client.getPrimaryPresenceForEntity(jid) , but here this method always returns null , please let me know if anything i need to do in order to check the connection status of the toUser before sending him message .

Regards

Shahzad

2 Replies 2

Geevarghese Cheria
Cisco Employee
Cisco Employee

Hi Shahzad,

  Please have a look to this url- https://developer.cisco.com/site/collaboration/jabber/websdk/learn/im-and-presence-how-to/use-jabber-im-core-apis/ for related information.

Thanks and Regards,

Geevarghese

Hi Shahzad,

You can get the roster entityset from the client and loop through the entities array as below. Then you get check the presence status for that given jid.

var client = new jabberwerx.Client('basic chat');

new jabberwerx.RosterController(client);

var jids = client.entitySet.toArray();     //Get the entitySet from current client

var rosterpresence;

var myentity = jabberwerx.RosterContact;

for(var i=0; i<jids.length; i++) {          //Loop through the entitySet Array

  myentity = jids[i];

  if(myentity.identities == "") {

  rosterpresence = myentity.getPrimaryPresence();     //Get primary presence from each RosterContact

  if (rosterpresence) {

  show = rosterpresence.getType() ||

  rosterpresence.getShow() ||

  "available";

  status = rosterpresence.getStatus();     //Get the status of this entity, the Roster

  }

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

  }

Regards,

Howard