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:
parent
345a5512ab
commit
76777b74b4
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user