TD2: Make the client send and receive object message.
[TD_SR.git] / TD2 / client / ThreadClientoSend.java
1 import java.io.*;
2
3 public class ThreadClientoSend implements Runnable {
4 private SocketClient client;
5
6 ThreadClientoSend(SocketClient c) {
7 client = c;
8 }
9
10 public void run() {
11 BufferedReader userInput = null;
12 try {
13 userInput = new BufferedReader(new InputStreamReader(System.in));
14 boolean end = false;
15 while (!end) {
16 String line = userInput.readLine();
17 if (line.equals(".")) {
18 end = true;
19 }
20 Message oMsg = new Message("Name", line);
21 client.sendoMsg(oMsg);
22 System.out.println(Thread.currentThread().getName() + " a envoye " + oMsg);
23 }
24 }
25 catch (IOException e) {
26 System.err.println("IOException: " + e);
27 e.printStackTrace();
28 }
29 finally {
30 if (userInput != null) {
31 try {
32 userInput.close();
33 }
34 catch (IOException e) {
35 System.err.println("IOException: " + e);
36 }
37 }
38 }
39 }
40 }