I have a client that I want to autmatically accept all subscriptions. I’'ve used this code:
// Add listener to process roster/presence messages
roster = connection.getRoster();
roster.setSubscriptionMode(Roster.SUBSCRIPTION_ACCEPT_ALL);
/code
When running like this, it works fine, other clients get subscribed properly.
However, I want to get notified when presence is changed, so I’'ve implemented this:
roster.addRosterListener(new RosterListener()
{
public void entriesAdded(Collection addresses)
{
}
public void entriesDeleted(Collection addresses)
{
}
public void entriesUpdated(Collection addresses)
{
}
public void presenceChanged(String user)
{
if(roster.getPresence(user)==null)
{
reportPresence(user,false);
}
else
{
reportPresence(user,true);
}
}
}
);
/code
However with this code in place, the subscription does not work anymore. Clients will NOT get subscribed until I restart my program. What could be the problem? Do I have to do something specific in the entriesAdded/entriesDeleted/entriesUpdated to have the automatic system still work?