- while (true) {
- try {
- client.sendMsg(msg);
- System.out.println (Thread.currentThread().getName() + " a envoye " + msg);
- try {
- Thread.sleep(ThreadLocalRandom.current().nextInt(101));
- }
- catch (InterruptedException e) {
- System.err.println("InterruptedException: " + e);
- }
- }
- catch (Exception e) {
- System.err.println("Exception: " + e);
+ BufferedReader userInput = null;
+ try {
+ userInput = new BufferedReader(new InputStreamReader(System.in));
+ boolean end = false;
+ while (!end) {
+ String line = userInput.readLine();
+ if (line.equals(".")) {
+ end = true;
+ }
+ client.sendMsg(line);
+ System.out.println(Thread.currentThread().getName() + " a envoye " + line);