powered by Jive Software

One more time: "Presence"

Hi folks,

I’‘ve a little problem here and can’'t get why.

I use the code above to determine available persons in the roster (I stripped the code here a little bit).

It is working great … most time, but sometimes it just says that the presence of some user could not be determined (which worked a few minutes before perfectly).

Any Help ??

Roster roster = xmppCon.getRoster();

RosterEntry entry;

for (Iterator i=roster.getEntries(); i.hasNext(); ) {

entry = (RosterEntry)i.next();

if (roster.getPresence(entry.getUser()) != null && roster.getPresence(entry.getUser()).getType() == Presence.Type.AVAILABLE) {

debug.writeDebugLog ("Request send to " + entry.getUser());

}

} else

if (roster.getPresence(entry.getUser()) != null)

debug.writeDebugLog (entry.getUser() + " is not available");

else

debug.writeDebugLog (entry.getUser() + " could not determine presence");

} // END -> for (Iterator i=roster.getEntries(); i.hasNext(); )

Try something like this

Iterator i = roster.getEntries();

while(i.hasNext()) {

RosterEntry entry = (RosterEntry)i.next();

Presence p = roster.getPresence(entry.getUser());

if(p != null) {

System.out.println(entry.getName() + ": " + p.getMode());

}

else {

System.out.println(entry.getName() + " : OFFLINE");

}

}

/code

hth

Jon

Hi Jon,

I’'ve implemented your code but the problem still remains

Edit:

I’'ve got the following scenario right now:

I’'ve opened one bot over my local adresse and another over mine dyndns-domain. The first bot only could determine the presence of one user, the other of both of my logins.

Sometimes it’'s just the other way. this is realy driving me crazy ^^.

(A spell check function, when editing a post, would be nice)

Message was edited by: Galeon

It may be that your contacts have not subscribed to each others Presence correctly.

Try and login with each of your contacts using a different client, such as Spark or Pandion and see if they are able to see each through them.