powered by Jive Software

Any idea why this code is not receiving incoming chat messages?

public class GoogleBotTest {

public static void main(String[] args) {

GoogleTalkConnection con = null;

try {

con = new GoogleTalkConnection();

con.login(“catchgod”, “king?”);

System.out.println("Logged into Google from ");

        Chat chat = con.createChat("testing@gmail.com");

chat.sendMessage(“Hello Senthoor”);

System.out.println(“AFter sending chat waiting for next message”);

while (true) {

// Wait for the next message the user types to us.

Message message = chat.nextMessage();

// Send back the same text the other user sent us.

chat.sendMessage(message.getBody());

}

} catch (XMPPException e) {

e.printStackTrace();

}

}

}

/code

the code is sending the message to google account but not receiving any message from google account? Any idea?

you need:

Chat.setFilteredOnThreadID(false);

/code

Thanks. It works now.

Whats exactly

Chat.setFilteredOnThreadID(false);

accomplishes?

You can have multiple ‘‘conversations’’ with the same participant. So, if you start a chat and assign it a thread ID, you have a mechanisim to distinguish the different converstations.

If the chat wasn’‘t created with a thread ID, then filtering on that parameter won’'t make sense.

-Ken

BTW, this logic has been improved for the next version of Smack. We now transparently track all the active Chat objects that are active with a user (using weak references). If a message comes in without a thread ID, Smack will automatically send it to the most recently created Chat with that user.

We’‘ve actually removed the setFilterOnThreadID method since it’‘s no longer needed. It’'s possible that we will deprecate and make it a no-op instead… still trying to balance out what the better approach is.

-Matt