TD2: Invert the stream on socket order: out first.
[TD_SR.git] / TD2 / server / BroadcastoThreadService.java
index 4c7281307fb3742d980cdeca342549f249511268..7aa05eb5229c91281bc53068cd0b3a1d3a33058f 100644 (file)
@@ -19,7 +19,8 @@ public class BroadcastoThreadService implements Runnable {
                try {
                        doService(clientSocket, listoWriter);
                        clientSocket.close();
-               } catch (IOException e) {
+               }
+               catch (IOException e) {
                        System.err.println("IOException : " + e);
                        e.printStackTrace();
                }
@@ -31,7 +32,8 @@ public class BroadcastoThreadService implements Runnable {
                        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<ObjectOutputStream> 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) {
@@ -59,10 +61,10 @@ public class BroadcastoThreadService implements Runnable {
                        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());
        }