From f428b2336f9e85a5e5947aa0d495d8cb2df25be9 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(); }