diff options
Diffstat (limited to 'src/Client/ChatClientReader.java')
-rw-r--r-- | src/Client/ChatClientReader.java | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/Client/ChatClientReader.java b/src/Client/ChatClientReader.java index 1734d18..487676a 100644 --- a/src/Client/ChatClientReader.java +++ b/src/Client/ChatClientReader.java @@ -1,10 +1,7 @@ package Client; import java.net.Socket; -import java.util.*; import java.io.*; -import javax.swing.JTextArea; - public class ChatClientReader extends Thread { private ChatClient client; @@ -13,14 +10,10 @@ public class ChatClientReader extends Thread /** constructor * @param the socket */ - public ChatClientReader (ChatClient client, Socket soc) + public ChatClientReader (ChatClient client, Socket soc, UserInterface ui) { this.client = client; this.soc = soc; - } - - public void setDisplay (UserInterface ui) - { this.ui = ui; } @@ -29,13 +22,13 @@ public class ChatClientReader extends Thread { try { - String line; InputStreamReader inputTemp = new InputStreamReader(this.soc.getInputStream()); BufferedReader input = new BufferedReader(inputTemp); - do { + while (true) + { line = input.readLine(); if (line == null) { @@ -43,8 +36,7 @@ public class ChatClientReader extends Thread System.err.println("The line is empty"); break; } - - //System.out.println(""); + System.out.println("Got line: [" + line + "]"); ParsedLine parsed = new ParsedLine(line); @@ -76,8 +68,7 @@ public class ChatClientReader extends Thread { ui.outputWriter("[" + line + "]"); } - } while (line != null); - // FIXME: close socket here? + } } catch (IOException e) { System.err.println(e); return; |