通过阅读 asmack 源码,在创建聊天室并邀请用户加入时,消息添加了 extension MUCUser.Invite
。
public void invite(Message message, String user, String reason) {
// TODO listen for 404 error code when inviter supplies a non-existent JID
message.setTo(room);
// Create the MUCUser packet that will include the invitation
MUCUser mucUser = new MUCUser();
MUCUser.Invite invite = new MUCUser.Invite();
invite.setTo(user);
invite.setReason(reason);
mucUser.setInvite(invite);
// Add the MUCUser packet that includes the invitation to the message
message.addExtension(mucUser);
connection.sendPacket(message);
}
我使用message.getExtension( "x","http://jabber.org/protocol/muc#user")
,但它返回 DefaultPacketExtension,而不是 MUCUser.Invite。所以我怀疑我怎么能得到邀请者的名字。任何帮助将不胜感激!