powered by Jive Software

Chat thread


I have some problems understanding the chatmanager.

I have this to receive all messages:


conn.getChatManager().addChatListener(new ChatManagerListener() {

public void chatCreated(final Chat chat, final boolean createdLocally) {

chat.addMessageListener(new MessageListener() {

public void processMessage(Chat chat, Message message) {

String sender=message.getFrom();

String body=message.getBody();

if(body != null)

System.out.println("Received message: " + sender + " " + body);





Now I have a msg command line function:


void msg(String to, String text)


Chat chat;



Lets say I have received a message first, so that a threadID has been created in #1.

Later I want to use msg() function to send a message to this JID.

As far as I understood I have to use the threadID which was created in #1. If I create a new thread in msg(), i will have 2 chats and 2 listeners for messages for the same participant.

So how do I find out the threadID in msg()?


Keep a reference to you chat when you were notified in the ChatListener and use it to send messages. It will already use the same thread ID as the incoming message.