I’m creating a Jabber client and trying to sort incoming messages by the sender, so that they can be displayed in the appropriate window. I thought it would be easiest to create a Conversation class that keeps track of all my client-specific formatting and associates it with the Jabber Chat. I then keep an ArrayList of ongoing Conversations. This way, as a new message comes in, I can add it to its Conversation, or create a new one for it it’s the first message.
The problem I’m having is this:
User 1 sends a message to my client.
Conversation is created for User 1.
User 2 sends a message to my client.
Conversation is created for User 2.
At this point, the ArrayList contains two conversations for User 2, and none for User 1.
If User 1 sends another message, the ArrayList will create a new conversation for User 1, but all the other conversations in the arraylist become conversations with User 1 as well.
Is this some sort of bug with Smack? I’m only calling the ArrayList.add() method once.
Also, is there a better way to handle sorting these incoming messages?
Thanks in advance!