【问题标题】:How to get inviter name by xmpp using amack?如何使用 amack 通过 xmpp 获取邀请者姓名?
【发布时间】:2012-12-24 02:12:41
【问题描述】:

通过阅读asmack源码,在创建聊天室并邀请用户加入时,消息添加了扩展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。所以我怀疑我怎么能得到邀请者的名字。 任何帮助将不胜感激!

【问题讨论】:

    标签: android xmpp smack asmack


    【解决方案1】:

    使用message.getBody()可以获取邀请原因和包含邀请人姓名的内容。使用 subString(),我得到了邀请者的名字。 但我认为这不是一个好的解决方案,我在问题中的疑问没有解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      • 2017-04-06
      • 2020-10-20
      • 1970-01-01
      相关资源
      最近更新 更多