threadID differs

  • Here is the code:
    XMPPConnection connection = new XMPPConnection(“server”);

connection.connect();

connection.login(“login”, “password”);

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

       @Override

       public void chatCreated(Chat chat, boolean createdLocally) {

            System.out.println(chat.getThreadID());

       }

  });
  • And a situation:
    Every time I send a message from another account to this, different thread ID is printed.

If I add an MessageListener to this chat, it receives mesage only once. I can send messages via this chat

but I can’t receive using MessageListener

It means:

  1. On every message new chat is created

  2. Chat id changes on every message

  • What am I asking for:
    I am looking for a code that can save a chat instance(when it is initiated outside) to use it to receive and send messages