I have a roster which I iterate through to get the presence info.
I can see that all the entries are iterated but the presence for all is null
Presence presence = roster.getPresence(entry.getUser());
gives presence = null
Now I know you need to be subscribed to each other to make this happen and I am subscribed and subscription = both.
I have Gaim opened and see the subscription = both but yet it is not noticed. Does anybody have a solution?
My code:
public String any_person_available (XMPPConnection conn, String emailgroup) {
Roster roster = conn.getRoster();
Presence presence;
RosterEntry entry;
for (Iterator i=roster.getEntries(); i.hasNext(); ) {
entry = (RosterEntry) i.next();
if (entry != null) {
presence = roster.getPresence(entry.getUser());
if (presence == null) {
System.out.println(“Presence is null”);
}
System.out.println(“Present are:”);
System.out.println(entry.getUser());
if (presence != null && presence.getType() == Presence.Type.AVAILABLE) {
// aanwezig dus klaar, return deze persoon
return entry.getUser();
}
}
}
return null;
}