X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD2%2Fserver%2FBroadcastThreadService.java;h=4bb29435b74ebcd62f554aa4399586cd209a513a;hb=ef87f1a8633012e6ba3ba20d095a619b7387ab49;hp=cd971c252356d34b4821c6e170ec81aa462d6c46;hpb=da31e6daf7553c6b38ca83c428dd02a3aa8af853;p=TD_SR.git diff --git a/TD2/server/BroadcastThreadService.java b/TD2/server/BroadcastThreadService.java index cd971c2..4bb2943 100644 --- a/TD2/server/BroadcastThreadService.java +++ b/TD2/server/BroadcastThreadService.java @@ -19,7 +19,8 @@ public class BroadcastThreadService implements Runnable { try { doService(clientSocket, listWriter); clientSocket.close(); - } catch (IOException e) { + } + catch (IOException e) { System.err.println("IOException : " + e); e.printStackTrace(); } @@ -27,7 +28,8 @@ public class BroadcastThreadService implements Runnable { try { if (this.clientSocket != null) this.clientSocket.close(); - } catch (IOException e) { + } + catch (IOException e) { System.err.println("IOException : " + e); e.printStackTrace(); } @@ -41,9 +43,9 @@ public class BroadcastThreadService implements Runnable { * @throws IOException [description] */ public void doService(Socket clientSocket, ArrayList sharedList) throws IOException { + PrintWriter OWriter = new PrintWriter(clientSocket.getOutputStream()); BufferedReader in; in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); - PrintWriter OWriter = new PrintWriter(clientSocket.getOutputStream()); sharedList.add(OWriter); boolean end = false; while (!end) { @@ -52,13 +54,14 @@ public class BroadcastThreadService implements Runnable { end = true; // le thread de service doit terminer break; // do not broadcast the dot that will close all clients threads } + System.out.println("Broadcasting the message <" + theLine + "> received from " + clientSocket.toString()); broadcastMsg(theLine); } sharedList.remove(OWriter); - if (in != null) - in.close(); if (OWriter != null) OWriter.close(); + if (in != null) + in.close(); System.out.println("Fin du thread repondant au client, port " + clientSocket.getPort()); }