Browse Source

refactoring: identation run()

remotes/origin/feature/client/make-input-field-buttons-interactive
Valentin Spiroski 11 months ago
parent
commit
c93929ef03
  1. 22
      src/main/java/ClientHandler.java

22
src/main/java/ClientHandler.java

@ -16,27 +16,32 @@ public class ClientHandler implements Runnable {
@Override
public void run() {
try {
fromClientReader = new BufferedReader(new InputStreamReader(connectionToClient.getInputStream()));
toClientWriter = new PrintWriter(new OutputStreamWriter(connectionToClient.getOutputStream()));
fromClientReader = new BufferedReader (new InputStreamReader(connectionToClient.getInputStream()));
toClientWriter = new PrintWriter (new OutputStreamWriter(connectionToClient.getOutputStream()));
chatServer.broadcastMessage(name + " connected.");
String message = fromClientReader.readLine();
while (message!=null) {
chatServer.broadcastMessage(name + ": " + message);
message = fromClientReader.readLine();
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
}
}
catch (IOException e) {
throw new RuntimeException(e);
}
finally {
//chatServer.removeClient(this);
chatServer.broadcastMessage(name + " disconnected.");
if (fromClientReader != null) {
try {
fromClientReader.close();
} catch (IOException e){
}
catch (IOException e){
e.printStackTrace();
}
}
@ -50,5 +55,4 @@ public class ClientHandler implements Runnable {
toClientWriter.println(message);
toClientWriter.flush();
}
}
Loading…
Cancel
Save