Fixed a problem in the examples where the client process does not shut itself down when a user typed the 'bye' command.

This commit is contained in:
Trustin Lee 2009-06-04 08:50:19 +00:00
parent 345a5512ab
commit 76777b74b4
2 changed files with 16 additions and 0 deletions

View File

@ -90,7 +90,16 @@ public class SecureChatClient {
if (line == null) {
break;
}
// Sends the received line to the server.
lastWriteFuture = channel.write(line + '\n');
// If user typed the 'bye' command, wait until the server closes
// the connection.
if (line.toLowerCase().equals("bye")) {
channel.getCloseFuture().awaitUninterruptibly();
break;
}
}
// Wait until all messages are flushed before closing the channel.

View File

@ -91,6 +91,13 @@ public class TelnetClient {
// Sends the received line to the server.
lastWriteFuture = channel.write(line + '\n');
// If user typed the 'bye' command, wait until the server closes
// the connection.
if (line.toLowerCase().equals("bye")) {
channel.getCloseFuture().awaitUninterruptibly();
break;
}
}
// Wait until all messages are flushed before closing the channel.