消息监听didnt收到完整的邮件ASMACK的Andr​​oid完整、邮件、消息、didnt

2023-09-03 22:54:12 作者:過期菂啨賰

我有问题,当想收到的消息,现在我能够收到消息,但一些attribut缺少

 类MyMessageListener实现消息监听{

    @覆盖
    公共无效而processMessage(聊天,留言消息){
        Util.DebugLog(MESSAGE->中+ message.toXmlns());

    }

}
 

我得到的是

 <消息=2@buzoo.bizTYPE =聊天,从=1@buzoo.biz/ff3b2485><车身ASDF =ASDF > AAA< /身体GT;< /消息>
 

talk_id和聊天式的内部邮件丢失。

这是要我要当收到消息

 <消息=2@buzoo.bizTYPE =聊天talk_id =304chat_type =0=1@buzoo.biz/ff3b2485 ><车身ASDF =ASDF> AAA< /身体GT;< /消息>
 

解决方案

虽然XMPP并未严格禁止通过添加自定义扩展一节的属性,以pre-定义的元素(的消息你的情况),这是最好的添加自定义的数据作为额外的元素。这是大多数XMPP扩展设计。

因此​​,而不是

 <消息=foo@bar.comTYPE =聊天myCustomData =myvalue的><身体GT;您好!< / BODY><消息&GT ;
 

 <消息=foo@bar.comTYPE =聊天><身体GT;你好<!/身体GT;< myExtension myCustomData =myvalue的 />< /消息>
 

然后你只需要编写一个提供程序 myExtension 并注册它啪的的ProviderManager

i got problem when want to receive message, right now i am able to receive message, but some attribut is missing

    class MyMessageListener implements MessageListener {

    @Override
    public void processMessage(Chat chat, Message message) {
        Util.DebugLog("message->"+message.toXmlns());

    }

}

what i got is

  <message to="2@buzoo.biz" type="chat" from="1@buzoo.biz/ff3b2485"><body asdf="asdf">aaa</body></message>

talk_id and chat type inside message is missing.

This is want i want when receive message

  <message to="2@buzoo.biz" type="chat" talk_id="304" chat_type="0" from="1@buzoo.biz/ff3b2485"><body asdf="asdf">aaa</body></message>

解决方案

While XMPP does not strictly forbid extending a stanzas by adding custom attributes to pre-defined elements (message in your case), it's the best to add the custom data as extra element. This is how most XMPP extensions are designed.

So instead of

<message to="foo@bar.com" type="chat" myCustomData="myValue"><body>Hello!</body><message>

you have

<message to="foo@bar.com" type="chat"><body>Hello!</body><myExtension myCustomData="myValue"/></message>

Then you simply need to write a Provider for myExtension and register it with Smack's ProviderManager.