summaryrefslogtreecommitdiff
path: root/src/Client/ChatClientWriter.java
diff options
context:
space:
mode:
authordor <dor1_b@walla.com>2013-11-30 14:10:14 +0200
committerdor <dor1_b@walla.com>2013-11-30 14:10:14 +0200
commit666377971c25f19f4114632c1adc0ff7d5b17e99 (patch)
treee1f69568827b32a7eaac15de01cce78f124af88f /src/Client/ChatClientWriter.java
parentcc73f7814f82232ec09fb4849e28e8976ee6afae (diff)
Evolving the client
Diffstat (limited to 'src/Client/ChatClientWriter.java')
-rw-r--r--src/Client/ChatClientWriter.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/Client/ChatClientWriter.java b/src/Client/ChatClientWriter.java
index ba35bf2..76ff03d 100644
--- a/src/Client/ChatClientWriter.java
+++ b/src/Client/ChatClientWriter.java
@@ -5,32 +5,52 @@ import java.util.*;
public class ChatClientWriter extends Thread
{
+ private ChatClient client;
private Socket soc;
+ private BufferedWriter output;
public static Scanner reader = new Scanner(System.in);
- public ChatClientWriter(Socket soc)
+ public ChatClientWriter(Socket soc ,ChatClient client)
{
this.soc = soc;
+ this.client = client;
}
-
+
+ public void println(String line)
+ {
+ try
+ {
+ this.output.write(line, 0, line.length());
+ this.output.newLine();
+ this.output.flush();
+
+ } catch (IOException e) {System.err.print("failed to print line" + e);}
+
+ }
+
public void run()
{
try
{
OutputStreamWriter outTemp;
String line;
+
outTemp = new OutputStreamWriter(this.soc.getOutputStream());
- BufferedWriter output = new BufferedWriter(outTemp);
+ this.output = new BufferedWriter(outTemp);
+ println("NICK " + client.getNick());
+ // 0: mode (nothing special). *: unused in RFC 2812, server name in RFC 1459
+ println("USER " + client.getNick() + " 0 * :" + client.getRealname());
+
while (true)
{
System.out.print("Write here: > ");
line = reader.nextLine();
- output.write(line, 0, line.length());
- output.newLine();
- output.flush();
+ this.output.write(line, 0, line.length());
+ this.output.newLine();
+ this.output.flush();
}
} catch (IOException e) {}