tags:

views:

288

answers:

1

I'm trying to get the Jabber ID for a nick in a multi user chat, but the following code returns only null:

class JabberMUCMessageListenerAdapter implements PacketListener {

    private final MultiUserChat muc;

    public JabberMUCMessageListenerAdapter(MultiUserChat muc) {
         this.muc = muc;
    }

    @Override
    public void processPacket(Packet p) {
        if (p instanceof Message) {

            final Message msg = (Message) p;

            String jid = muc.getOccupant(msg.getFrom()).getJid(); // returns null

            ...
        }
    }
}

Does anyone know, what I'm doing wrong?

+1  A: 

http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smackx/muc/Occupant.html

The full JID and nickname are optional.

Vladimir Dyuzhev
"If this information was extracted from a presence and the room is semi or full-anonymous then the answer will be null."The 1st part is true, but I don't think that the room is anonymous (how do I find it out, if it is?)Using Pidgin I can access the JID, so there must be a way using Smack, too, mustn't it?
Kutzi