From a7daba9dadd2203bca0a5aad363bce89abe943c2 Mon Sep 17 00:00:00 2001 From: Valentin Spiroski Date: Sun, 4 Feb 2024 23:45:06 +0100 Subject: [PATCH] finally in run() --- src/main/java/ClientHandler.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/ClientHandler.java b/src/main/java/ClientHandler.java index c59f1ed..5561e3c 100644 --- a/src/main/java/ClientHandler.java +++ b/src/main/java/ClientHandler.java @@ -39,6 +39,20 @@ public class ClientHandler implements Runnable { } } catch (IOException e) { e.printStackTrace(); + } finally { + //chatServer.removeClient(this); + chatServer.broadcastMessage(name + " disconnected."); + + if (fromClientReader != null) { + try { + fromClientReader.close(); + } catch (IOException e){ + e.printStackTrace(); + } + } + if (toClientWriter != null) { + toClientWriter.close(); + } } }