From 10e138bc22262f629dcf56f5e3df948cf9cf4efb Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Sun, 4 Feb 2024 23:27:42 +0100 Subject: [PATCH] while loop in run() for waiting for new messages --- src/main/java/ClientHandler.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/ClientHandler.java b/src/main/java/ClientHandler.java index 6711e84..fe885bd 100644 --- a/src/main/java/ClientHandler.java +++ b/src/main/java/ClientHandler.java @@ -32,6 +32,11 @@ public class ClientHandler implements Runnable { 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) { e.printStackTrace(); }