X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD2%2Fclient%2FThreadClientoSend.java;h=2475be6d7c80245e5b00eb830d0ff4c778c14e85;hb=03a13b6164d44f0c74e5cd180abecbb8e0dda30a;hp=53fdeb07addee6917201d274057b4156a39dd0ab;hpb=da31e6daf7553c6b38ca83c428dd02a3aa8af853;p=TD_SR.git diff --git a/TD2/client/ThreadClientoSend.java b/TD2/client/ThreadClientoSend.java index 53fdeb0..2475be6 100644 --- a/TD2/client/ThreadClientoSend.java +++ b/TD2/client/ThreadClientoSend.java @@ -4,8 +4,7 @@ import java.util.Random; public class ThreadClientoSend implements Runnable { private SocketClient client; - //FIXME: use a random name by thread for now - // should setable + //FIXME: use a random name by thread for now, should be setable private String randName; ThreadClientoSend(SocketClient c) { @@ -34,14 +33,16 @@ public class ThreadClientoSend implements Runnable { try { userInput = new BufferedReader(new InputStreamReader(System.in)); boolean end = false; - while (!end) { - String line = userInput.readLine(); - if (line.equals(".")) { + while (!end) { + String line = userInput.readLine(); + if (line.equals(".")) { end = true; } - Message oMsg = new Message(randName, line, Calendar.getInstance()); - client.sendoMsg(oMsg); - System.out.println(Thread.currentThread().getName() + " a envoye " + oMsg); + if (!line.isEmpty()) { + Message oMsg = new Message(randName, line, Calendar.getInstance()); + client.sendoMsg(oMsg); + System.out.println(Thread.currentThread().getName() + " a envoye " + oMsg); + } } } catch (IOException e) { @@ -50,13 +51,14 @@ public class ThreadClientoSend implements Runnable { } finally { if (userInput != null) { - try { - userInput.close(); - } - catch (IOException e) { - System.err.println("IOException: " + e); - } - } + try { + userInput.close(); + } + catch (IOException e) { + System.err.println("IOException: " + e); + e.printStackTrace(); + } + } } } }