Commit | Line | Data |
---|---|---|
e018d1ec | 1 | import java.io.*; |
2c648f75 JB |
2 | |
3 | public class ThreadClientSend implements Runnable { | |
4 | private SocketClient client; | |
2c648f75 JB |
5 | |
6 | ThreadClientSend(SocketClient c) { | |
7 | client = c; | |
8 | } | |
9 | ||
2c648f75 | 10 | public void run() { |
e018d1ec JB |
11 | BufferedReader userInput = null; |
12 | try { | |
13 | userInput = new BufferedReader(new InputStreamReader(System.in)); | |
14 | boolean end = false; | |
fcb90b76 JB |
15 | while (!end) { |
16 | String line = userInput.readLine(); | |
6b300998 | 17 | if (line.equals(".")) { |
e018d1ec JB |
18 | end = true; |
19 | } | |
20 | client.sendMsg(line); | |
21 | System.out.println(Thread.currentThread().getName() + " a envoye " + line); | |
2c648f75 | 22 | } |
6b300998 | 23 | } |
e018d1ec JB |
24 | catch (IOException e) { |
25 | System.err.println("IOException: " + e); | |
26 | e.printStackTrace(); | |
27 | } | |
28 | finally { | |
29 | if (userInput != null) { | |
6b300998 JB |
30 | try { |
31 | userInput.close(); | |
32 | } | |
33 | catch (IOException e) { | |
34 | System.err.println("IOException: " + e); | |
8c3c3f61 | 35 | e.printStackTrace(); |
6b300998 JB |
36 | } |
37 | } | |
2c648f75 JB |
38 | } |
39 | } | |
40 | } |