Hi,
The processMessage of my MessageListener is no longer being called after I updated to asmack 4.0.
I looked at the constructor of the ChatManager and noticed that the packetListener is changed in smack 4.0.
Before 4.0 (0.8.10 to be specific), the code tries to get a Chat from the thread id obtained from the incoming message, and if it failed, it falls back to getUserChat, which will find the Chat correctly.
if (message.getThread() == null) { chat = getUserChat(message.getFrom()); } else{ chat = getThreadChat(message.getThread()); if (chat == null) { // Try to locate the chat based on the sender of the message chat = getUserChat(message.getFrom()); } }
However, after updating to 4.0, the code tries to get a Chat from the thread id of the message (a message will always have a thread id because Chat.sendMessage will always assign one to before sending), and if it fails, it will create a new Chat instead of going to getUserChat. So my processMessage is not called because a new Chat is created to deliver the message.
if (message.getThread() == null) { // it's never possible to get into this branch because getThread() is never null for a chat message chat = getUserChat(message.getFrom()); } else{ chat = getThreadChat(message.getThread()); // why is this part removed from 4.0??? }
So in order for the method processMessage to be called, both clients communicating with each other must have the same thread id. Is this a bug or intentional?
Thanks,
Ray