diff options
-rw-r--r-- | src/Client/ChatClient.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Client/ChatClient.java b/src/Client/ChatClient.java index ac76215..cabe967 100644 --- a/src/Client/ChatClient.java +++ b/src/Client/ChatClient.java @@ -9,6 +9,7 @@ import java.net.Socket; + import Server.ChatServer; import Server.Client; @@ -18,6 +19,11 @@ public class ChatClient private String realname; private ChatClientWriter writer; private UserInterface ui; + private Socket soc; + + ChatClient() { + this.soc = null; + } /** returning the nick name */ public String getNick () @@ -58,10 +64,20 @@ public class ChatClient } } + public void shutdown() + { + if (soc != null) + { + try + { + soc.close(); + } + catch (IOException e) {} + } + } + public boolean connect (String host, int port) { - Socket soc; - try { soc = new Socket(host, port); @@ -123,6 +139,9 @@ public class ChatClient * * Pressing Enter in the message line does not send text. * * Configuration file to save the nick? * * History log? + * * In the end: + * * Close socket + * * Send QUIT before that (QUIT :leaving) * * It may be handy to implement other client commands: * - /NICK - changes the nick * - /CLEAR - clears the output window |