开发者

SMACK Message Listener for XEP-0022 does not get called

I am not able to receive XMPP messages, I am using the following code:

    Message mess = new Message() {
           @Override
           public String toXML() {
           return "<message to='user@50.17.86.32' id='message22'><body>Great    Mesg</body><x xmlns='jabber:x:event'><offline/><delivered/><composing/></x></message>";
          }
    };


    PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
    connection.sendPacket(mess);
    connection.addPacketListener(new PacketLis开发者_开发问答tener() {
            public void processPacket(Packet packet) {
              Message message = (Message) packet;
              Log.d("Recv", "Message: " + message.toXML());
          }
    }, filter);

Basically I am using patched version of SMACK for android....and trying to get message states using xep 0022.


I think your filter is the cause of your problem. If your incoming messages do not have the type='chat' attribute defined, then they will be of type Message.Type.normal. I am only guessing of course since you did not post the incoming message, but the one you send does not include a type.

You may want just create a ChatManagerListener and register it with the ChatManager instead. This will then handle this case.

Note: You are aware that XEP-0022 is obsolete right?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜