TD2: Ensure chat clients will not send empty message.
[TD_SR.git] / TD2 / IHM / ThreadIHMSend.java
1 import java.io.*;
2
3 public class ThreadIHMSend implements Runnable {
4 private SocketClient client;
5 private IHM clientIHM;
6
7 ThreadIHMSend(SocketClient c, IHM ui) {
8 client = c;
9 clientIHM = ui;
10 }
11
12 public void run() {
13 try {
14 boolean end = false;
15 while (!end) {
16 String line = clientIHM.getNextMessageToSend();
17 if (line.equals(".")) {
18 end = true;
19 }
20 if (line.length() != 0) {
21 client.sendMsg(line);
22 System.out.println(Thread.currentThread().getName() + " a envoye " + line);
23 }
24 }
25 }
26 catch (Exception e) {
27 System.err.println("Exception: " + e);
28 e.printStackTrace();
29 }
30 }
31 }