TD2: Make the IHM client with one receive thread and one send thread.
[TD_SR.git] / TD2 / IHM / ThreadIHMReceive.java
1 import java.io.*;
2
3 public class ThreadIHMReceive implements Runnable {
4 private SocketClient client;
5 private IHM clientIHM;
6
7 ThreadIHMReceive(SocketClient c, IHM ui) {
8 client = c;
9 clientIHM = ui;
10 }
11
12 public void run() {
13 try {
14 boolean end = false;
15 //FIXME: not exiting properly randomly from that loop!
16 while (!end) {
17 String rline = client.receiveMsg();
18 if (rline.equals(".")) {
19 end = true;
20 }
21 clientIHM.writeMessage(rline);
22 System.out.println(Thread.currentThread().getName() + " a recu " + rline);
23 }
24 }
25 catch (IOException e) {
26 System.err.println("IOException: " + e);
27 e.printStackTrace();
28 }
29 }
30 }