repositories
/
TD_SR.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Coding style cleanups.
[TD_SR.git]
/
TD2
/
server
/
BroadcastThreadService.java
diff --git
a/TD2/server/BroadcastThreadService.java
b/TD2/server/BroadcastThreadService.java
index daf753f665ab16d9e798dcbc45428ce2b0732774..7a39e7a72f4ba3384973baf9a5d717a10460f998 100644
(file)
--- 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();
try {
doService(clientSocket, listWriter);
clientSocket.close();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
System.err.println("IOException : " + e);
e.printStackTrace();
}
System.err.println("IOException : " + e);
e.printStackTrace();
}
@@
-27,13
+28,20
@@
public class BroadcastThreadService implements Runnable {
try {
if (this.clientSocket != null)
this.clientSocket.close();
try {
if (this.clientSocket != null)
this.clientSocket.close();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
System.err.println("IOException : " + e);
e.printStackTrace();
}
}
}
System.err.println("IOException : " + e);
e.printStackTrace();
}
}
}
+ /**
+ * Be careful, this function must be thread-safe
+ * @param clientSocket [description]
+ * @param sharedList [description]
+ * @throws IOException [description]
+ */
public void doService(Socket clientSocket, ArrayList<PrintWriter> sharedList) throws IOException {
BufferedReader in;
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
public void doService(Socket clientSocket, ArrayList<PrintWriter> sharedList) throws IOException {
BufferedReader in;
in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
@@
-44,7
+52,7
@@
public class BroadcastThreadService implements Runnable {
String theLine = in.readLine();
if (theLine.equals(".")) {
end = true; // le thread de service doit terminer
String theLine = in.readLine();
if (theLine.equals(".")) {
end = true; // le thread de service doit terminer
- break; // do not broadcast the dot that will close clients threads
+ break; // do not broadcast the dot that will close
all
clients threads
}
broadcastMsg(theLine);
}
}
broadcastMsg(theLine);
}