powered by Jive Software

Presence Information

I understand that the Presence information is asynchronous, which explains why roster.getPresence return unavailable for nearly every user. However, I only receive presence changes (from my RosterListener) for a very small number of my contacts on my contact list. I’‘ve figured out how to connect and process the Roster, but I can’‘t seem to figure out how to reliably get the Presence information. Essentially all I’'m trying to do is duplicate the functionality of Spark where you connect and it displays a list of your users and their Presence information.

I assumed that presenceChanged would be invoked for every online user as it receives information for each user, but it seems that is not so…

Help very appreciated.

I was having some problems with message delivery notifications that sound similar to what you described. Adding the following caused all events to work (for reasons unknown). It’'s worth a shot.

xmpp.addPacketListener(new PacketListener() { public void processPacket(Packet p) {} }, new PacketFilter() { public boolean accept(Packet p) { return false;} });

I have been able to get presenceChanged events for all users in my roster using Smack 3.0.0. I attach the RosterListener after the login method completes and it seems to work fine. Maybe you could provide more information on your environment/setup? One thought, are you properly subscribed to all the users you are trying to get presence information for?

Nope, that made no difference.

I would have expected every user on the roster would receive a presenceChanged event but that’‘s just not happening. I could even understand if it were only for online users, but it’'s just sending a few…

I would think this would be a simple problem…is there not an easy solution to determine the Presence information without adding arbitrary wait-states and just checking back to see if it has a status assigned yet?

I think Chris was on the right track. You might be trying to read presence info before you’'re finished logging in. Also, it may not call presenceChanged for each entry when you log in. Maybe you need to read their initial presences with Roster.getPresence, and then watch for subsequent changes using the RosterListener.