I just started using the smack library and I’'m having problems retrieving presence information from a roster.
I can setup a packetfilter to collect presence packets after the client is already logged in and it works fine when someone changes their status. But I need find the status of each user on the roster when the client is first starting up.
My roster object is definately populated with JIDs. I can iterate through it and see each one. The problem is that Roster.getPresence(“someuser”) always returns null instead of a presence object. Here’‘s what I’'m trying:
roster = connection.getRoster();
Presence presence = roster.getPresence(“user@localhost”);
if (presence.getType() == Presence.Type.UNAVAILABLE) { …
presence.getType() always throws a null pointer exception.
I ran the debug and can see the contact information coming in a soon as the connection is made but the call to roster.getPresence() doesn’'t seem to generate any traffic at all.
Any idea what I’'m missing here?
Thanks for the help!