Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Problem with ChatManager logic with thread IDs

$
0
0

Hi,

 

we have the following scenario:

 

User A and User B are logged in to Openfire.

User A creates a Chat with the ChatManager, which generates a ThreadID, let's say "1" and sends a message to User 2.

 

The ChatManger of User 2 receives the message and creates a new Chat object based on the message, since it can't find the chat in the "threadChats" nor in "userChats" variables.

 

So far it's fine, both users chat with each other using the same ThreadID.

 

Now User A restarts his application and wants to continue the conversation with User 2. A new Chat object is created with a NEW threadID, let's say "2".

 

User B receives the message and can't find the threadID in the threadChats variable, BUT in the userChats variable. So it takes this chat object, which has still the OLD threadID.

 

User B responds and writes a message to User A using the OLD threadID. User A receives the message and can't find the old thread ID, but only the new threadID in the userChats variable.

 

The problem now is, that user A sends his message with threadID "2" and user 2 sends his messages with the old threadID "1".

 

This is problematic because we work with the thread ID to store old conversations. If the actually same conversation uses different thread IDs we can't relate messages properly.

 

I am talking about this code snippet:

 

connection.addPacketListener(new PacketListener() {            publicvoid processPacket(Packet packet) {                Message message = (Message) packet;                Chat chat;                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()); // THIS IS THE PROBLEMATIC CODE.                    }                }                 if (chat == null) {                    chat = createChat(message);                }                deliverMessage(chat, message);            }        }, filter);

 

Any comments on this issue?

 

Will it be fixed, by simply removing the fallback mechanism OR by reassigning the threadID of the message to the found chat object?


Viewing all articles
Browse latest Browse all 10742

Trending Articles