MUC Occupant information not available on presence change

Hi,

I’m developing an Android application with the help of asmack and I’m having some problems with MUC integration.

I registered a listener to the Presence packets:

mMUCCurrent.addParticipantListener(new PacketListener() {

@Override

public void processPacket(Packet packet) {

Presence presence = (Presence) packet;

OpenfireChat.this.fireOnChatPresenceChanged(presence);

}

});

And inside the fireOnChatPresenceChanged(presence) method I’m trying to retrieve the information about the user that just connected/disconnected:

Occupant occupant = null;

try {

occupant = mMUCCurrent.getOccupant(message.getFrom());

} catch (Exception e) {

e.printStackTrace();

}

As you can see, I had to use the try-catch clause because in 50% of the cases the getOccupant() method throws and exception as if the Occupant is no longer / not yet there. I verified this by iterating over mMUCCurrent.getOccupants(). However, the exact behavior here is not defined. Someties the Occupant is available on Presence.Type.available and sometimes on Presence.Type.unavailable packets. It’s always one or the other.

Is there any way to get some information about the user just joining the chatroom? I’m mostly interested in getting their jid since I need it to get their VCard to get their avatar. Unless there’s also an easier way to get their avatar directly from the MUC mechanisms.

Thanks for all your help!