From 02e6012ca5983d52441560ecd737267bdaaecf93 Mon Sep 17 00:00:00 2001 From: Dor Bivas Date: Sat, 18 Jan 2014 18:22:42 +0200 Subject: client: fix QUOTE, isConnected * Add attribute isConnected. * Handling of /QUOTE: there is the extra space. --- src/Client/ChatClient.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Client/ChatClient.java b/src/Client/ChatClient.java index 6099474..bcc5612 100644 --- a/src/Client/ChatClient.java +++ b/src/Client/ChatClient.java @@ -20,6 +20,7 @@ public class ChatClient private ChatClientWriter writer; private UserInterface ui; private Socket soc; + private boolean isConnected = false; ChatClient() { this.soc = null; @@ -40,22 +41,34 @@ public class ChatClient { this.nick = nick; } - /** changing the real name */ + /** changing the real name + * @param realname the name to set*/ public void setRealname (String realname) { this.realname = realname; } + /** mark client as connected */ + public void setConnected() + { + this.isConnected = true; + } + + /** send a line to server */ public void runSendline (String line) { + if (!this.isConnected) + return; + writer.sendLine(line); } + /** */ public void PRIVMSG (String line) { - if ((line.length() >= 6) && (line.substring(0,6)).equals(new String("/QUOTE"))) + if ((line.length() >= 7) && (line.substring(0,7)).equals(new String("/QUOTE "))) { - runSendline(line.substring(6, line.length())); + runSendline(line.substring(7, line.length())); } else -- cgit v1.2.3