有一个MessageListener监听processMessage说来自用户A,当sendMsg从另一个用户发送到用户A时,我看到processMessage被调用了两次:
public void sendMsg(message){
Message msg = new Message();
mess.setBody(message);
// userid is the userid to whom the message will be sent to and chmanage is an instance of Chat Manager
Chat chat = chmanage.createChat(<userid>, new CListener());
chat.sendMessage(msg);
}
class CListener implements MessageListener{
@Override
public void processMessage(Chat chat, Message message) {
...
//this gets called twice
}
}
有什么理由吗?我应该使用其他东西,比如创建PacketCollector或PacketListener吗?
答案 0 :(得分:0)
两次使用Listener来监听消息并将其注册到另一个用户。它为该
创建一个单独的监听器类后起作用