diff options
author | Dor Bivas <dor1_b@walla.com> | 2013-12-21 18:10:46 +0200 |
---|---|---|
committer | Dor Bivas <dor1_b@walla.com> | 2013-12-21 18:10:46 +0200 |
commit | 40428070f2c0c362a4164d41b86ae003d9711120 (patch) | |
tree | b35d9bfac4367947ae26b0ab96af94c752e1ab6e | |
parent | 53d13d1f94b03edbf308c50426a9c465a79f8789 (diff) |
client: A separate shutdown function for socket
-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 |