powered by Jive Software

Managing Roster List Presence


I have a simple request.

I just tried smack. It works great except for on thing I cannot get to work: RosterList Presence.

I simply would like to be informed about my RosterList contacts presence modification.

So I used a RosterListner. But the status modifications are never considered.

here’'s the code I tried:

//ADDING a Roster Listener

final Roster roster = connection.getRoster();

roster.addRosterListener(new RosterListener() {

public void rosterModified() {

// Ignore event for this example.


public void presenceChanged(String user) {

// If the presence is unavailable then “null” will be printed,

// which is fine for this example.

System.out.println("Presence changed: " + roster.getPresence(user));



Even when I just try to get the RosterList and the status (not dynamic), I get the Rosters but always NULL for the satus.

can somebody help?

Are you sure that your application is waiting long enough for the presense information to be delivered by the server? One tricky thing about XMPP is that much of the protocol is non-blocking – ie, we never know when the server is going to deliver presence info. Also, null means offline. So, are you sure that people on your roster are online? If you are sure, make sure that your application is staying active and isn’‘t quiting as soon as the listener is added. That wouldn’'t allow enough time for the presence info to be delivered.



I guess you must be right. Effectively I don’'t wait that much.

I’'ll try that thanks.

In fact, I try what you said.

But it seems that it still doesn’'t work.

What did you mean by “your application waits long enough”?

Is that when I try to get the RosterList informations?

Because now I stay connected for a while, I still can’'t get the good presence information.

Don’'t you see nothing wrong in my code? (upper)