X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TD2%2Fserver%2FBroadcastoThreadService.java;h=3431b77e0f5bd7bce763013435f1263d706e8571;hb=ef87f1a8633012e6ba3ba20d095a619b7387ab49;hp=4c7281307fb3742d980cdeca342549f249511268;hpb=3d59b440efb79d37563fe45a6cb6a9b36c201158;p=TD_SR.git diff --git a/TD2/server/BroadcastoThreadService.java b/TD2/server/BroadcastoThreadService.java index 4c72813..3431b77 100644 --- a/TD2/server/BroadcastoThreadService.java +++ b/TD2/server/BroadcastoThreadService.java @@ -19,19 +19,21 @@ public class BroadcastoThreadService implements Runnable { try { doService(clientSocket, listoWriter); clientSocket.close(); - } catch (IOException e) { + } + catch (IOException e) { System.err.println("IOException : " + e); e.printStackTrace(); } catch (ClassNotFoundException e) { - System.err.println("ClassNotFoundException: " + e); + System.err.println("ClassNotFoundException: " + e); e.printStackTrace(); } finally { try { if (this.clientSocket != null) this.clientSocket.close(); - } catch (IOException e) { + } + catch (IOException e) { System.err.println("IOException : " + e); e.printStackTrace(); } @@ -46,8 +48,8 @@ public class BroadcastoThreadService implements Runnable { * @throws ClassNotFoundException [description] */ public void doService(Socket clientSocket, ArrayList sharedList) throws IOException, ClassNotFoundException { - ObjectInputStream OReader = new ObjectInputStream(clientSocket.getInputStream()); ObjectOutputStream OWriter = new ObjectOutputStream(clientSocket.getOutputStream()); + ObjectInputStream OReader = new ObjectInputStream(clientSocket.getInputStream()); sharedList.add(OWriter); boolean end = false; while (!end) { @@ -56,13 +58,14 @@ public class BroadcastoThreadService 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 <" + roMsg + "> received from " + clientSocket.toString()); broadcastoMsg(roMsg); } sharedList.remove(OWriter); - if (OReader != null) - OReader.close(); if (OWriter != null) OWriter.close(); + if (OReader != null) + OReader.close(); System.out.println("Fin du thread repondant au client, port " + clientSocket.getPort()); }