Browse Source

while loop in run() for waiting for new messages

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

5
src/main/java/ClientHandler.java

@ -32,6 +32,11 @@ public class ClientHandler implements Runnable {
toClientWriter = new PrintWriter(new OutputStreamWriter(connectionToClient.getOutputStream())); toClientWriter = new PrintWriter(new OutputStreamWriter(connectionToClient.getOutputStream()));
chatServer.broadcastMessage(name + " connected."); chatServer.broadcastMessage(name + " connected.");
String message = fromClientReader.readLine();
while (message!=null) {
chatServer.broadcastMessage(name + ": " + message);
message = fromClientReader.readLine();
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

Loading…
Cancel
Save