Roster getPresence ignores presence type?

Hi,

In smack 3.0.4 & 3.1.0, Roster.getPresence() ignores the presence type when selecting the presence with the highest priority.

If more than one presence entries for the same user, same priority and different resources are stored in the roster, the current implementation will choose the presence with the highest availability. While searching for the highest availability it does not consider the presence type. Thus when there are 2 entries with same priority, null mode and Type.available & Type.unavailable types respectively, the roster returns one of them randomly depending on which one comes first in the java map.

The problem manifests when a user logs in and out 3-4 times with different resources. Other users correctly see the new available presence in the PresenceListener but often get an unavaillable presence in Roster.getPresence().

Is this a bug or we shoud use presence priorities or fixed resources when connecting?

Thanks

I have had to work around this issue as well. My problem was to send to all available presence resources.

getRoster().getPresences(userName)

then iterate through each returned presence and send to all of the chat and available presences.

I guess I could be a little more clear in my previous answer.

Here is the code that I implemented to find the available presences of the user that I care about.

RosterEntry entry = getConnection().getRoster().getEntry(“Joe”);

Iterator aPresenceItr = …getConnection().getRoster().getPresences(entry.getUser());

while (aPresenceItr.hasNext()) {

Presence presence = aPresenceItr.next();

if(presence.isAvailable()) {

do Stuff here, like

presence.getFrom();

}

}