Browse Source

refactoring: comments run() try

remotes/origin/client-handler
Valentin Spiroski 11 months ago
parent
commit
1a284c164a
  1. 6
      src/main/java/ClientHandler.java

6
src/main/java/ClientHandler.java

@ -20,12 +20,16 @@ public class ClientHandler implements Runnable {
public void run() {
try {
// Set up input and output streams for communication with the client
fromClientReader = new BufferedReader (new InputStreamReader(connectionToClient.getInputStream()));
toClientWriter = new PrintWriter (new OutputStreamWriter(connectionToClient.getOutputStream()));
chatServer.broadcastMessage(name + " connected.");
chatServer.broadcastMessage(name + " connected."); // Broadcast a message when the client is connected
// Read messages from the client and broadcast them to all clients
String message = fromClientReader.readLine();
while (message!=null) {
// Broadcast the client's message to all connected clients
chatServer.broadcastMessage(name + ": " + message);
message = fromClientReader.readLine();
}

Loading…
Cancel
Save