Multiple chat instances with different ThreadIDs between two agents

Hi,

I need help: I have two instances of my program communicating with each other.

1 => create new chat to 2 with threadidXYZ and send message

2 => receives message from 1 and create new chat to 1 with threadidABC and send message.

1 => receives message from 2 but with its own threadidXYZ rather than the expect new chatid!

Is that the desired behavior? Can I fix it?

Jan

Hi,

I think that is by design, but I’m not completely sure. I think the client tries to maintain its own thread ID as long as the conversation is going. Looking at the code I see the following:

ChatManager (100-120) => It first tries to look up a message using the thread ID of the received message. This would return nothing, so then it tries to find a matching chat using the From User ID. This would find your original Chat object, so the message is given to that chat.

Chat (162-171) => The chat object explicitly overwrites the thread ID of any message that it receives to match its original value.

So I think these are your options:

1.) Just send a message without maintaining a reference to the Chat object, then the incoming response would look like a new conversation to the receiver, which would cause a new Chat to be created with the new thread ID.

2.) Change the Smack code referenced above in the Chat object to not overwrite the thread ID if the message already has one.

Chris

Thanks, now I know that it’s not completely my fault.

I tried to ignore the Chat stuff and send plain Packets:

//connect etc.

Message xm = new Message();

xm.setThread(“xy”);

xm.setBody(message);

xmpp.sendPacket(xm);

but afterwards the connection is silently closed, no message is sent and any futher attemp to send a message gets a not -connected exception.

Is it not alllowed what I’m doing?

Maybe I have to write my own ChatManager…

Jan

Did you remember to call xm.setTo(jabberId); to tell it which user this message should be sent to?

Chris

it just came over me when I re-read my post. I’d vote for an exception to prevent other idiots doing the same as I did