XEP-0022 的 SMACK 消息侦听器不会被调用
我无法接收 XMPP 消息,我使用以下代码:
Message mess = new Message() {
@Override
public String toXML() {
return "<message to='[email protected]' 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 PacketListener() {
public void processPacket(Packet packet) {
Message message = (Message) packet;
Log.d("Recv", "Message: " + message.toXML());
}
}, filter);
基本上我使用的是 Android 版 SMACK 的修补版本......并尝试使用 xep 0022 获取消息状态。
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='[email protected]' 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 PacketListener() {
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的过滤器是造成问题的原因。如果您传入的消息没有定义 type='chat' 属性,那么它们的类型将为 Message.Type.normal。我当然只是猜测,因为您没有发布传入消息,但您发送的消息不包含类型。
您可能只想创建一个 ChatManagerListener 并将其注册到 ChatManager。然后这将处理这种情况。
注意:您知道 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?