我正在尝试在多用户聊天中获取昵称的 Jabber ID,但以下代码仅返回 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
...
}
}
}
有谁知道,我做错了什么?