ChatManager listens to messages with type="normal"

Hi,

in our application we send and receives messages with type=“normal”. The purpose of these messages is obviously not to use in a chat window, but to use them to transport PacketExtensions for other purposes.

We use messages, because they also need to be stored by Openfire in case the recipient is offline.

We also want to use a different Thread ID for these messages to keep track of associated messages.

However, the ChatManager listens for all messages with type=“chat” AND type=“normal”. That means it listens to our “normal” messages and assigns a Chat to them. When the user has used the chat, a chat object is created for the user.

Now, when a normal message arrives, it can’t find a ThreadChat (due to different thread id), so it takes the next best available according to the user.

Later in the Chat class, the deliver method overrides the thread id with the one for the chat.

This is problematic for us, because we cannot differentiate messages by their thread id anymore.

In my opinion, the ChatManager should only listen for messages of type=“chat”. This would fix our problem and makes semantically more sense. The Chat#sendMessage methods also set the type “chat”.

Do you have any opinions about that?

Is there any chance, this will get fixed any time soon, if at all?

It would be just adjusting the PacketFilter in ChatManager.java in line 104.

Regards!

Nobody has to say something about this topic?

Logged as SMACK-387. If you would like to provide a patch, please attach it to this thread and I will add it to the task. If you do, make sure to not change the default behaviour.

Thanks for opening an issue in Jira. I don’t know how to provide a patch for Smack. In my opinion the only the thing which should change is the PacketFilter in the constructor of ChatManager.java to only allow chat messages:

PacketFilter filter = new PacketFilter() {

public boolean accept(Packet packet) {

if (!(packet instanceof Message)) {

return false;

}

Message.Type messageType = ((Message) packet).getType();

return messageType == Message.Type.chat;

}

};