powered by Jive Software

How to close GoogleTalkConnection

I log in with a@gmail.com, and create chat with b@gmail.com.and i can send and receive message.but after i stop the program, i find a@gmail is in the on-line list,

and it can answer my message.

I think it is because i did not close the connection in program,so i add finally block to close the connection,but

i encountered the same problem.

public static void main(String args[]) {

GoogleTalkConnection con = null;

Chat chat;

try {

con = new GoogleTalkConnection();

con.login(“a”, “pwd”);

Chat.setFilteredOnThreadID(false);

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

while (true) {

Message message = chat.nextMessage();

System.out.println(message.getBody());

chat.sendMessage(“Hello”);

}

} catch (XMPPException e) {

e.printStackTrace();

} finally {

if (con != null)

con.close();

}

}

Anybody can help me with this.

More thanks…

Quick.

Message was edited by:

quicknow

Message was edited by:

quicknow

Message was edited by:

quicknow

it is because the previous connection did not close.

actually con.close() works.