|
@ -36,13 +36,13 @@ public class ClientHandler implements Runnable { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
catch (IOException e) { |
|
|
catch (IOException e) { |
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
|
throw new RuntimeException(e); // Handle exceptions by throwing a runtime exception |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
finally { |
|
|
finally { |
|
|
//chatServer.removeClient(this); |
|
|
//chatServer.removeClient(this); |
|
|
chatServer.broadcastMessage(name + " disconnected."); |
|
|
|
|
|
|
|
|
chatServer.broadcastMessage(name + " disconnected."); // Broadcast a message when the client is disconnected |
|
|
|
|
|
|
|
|
|
|
|
// Close resources in the finally block |
|
|
if (fromClientReader != null) { |
|
|
if (fromClientReader != null) { |
|
|
try { |
|
|
try { |
|
|
fromClientReader.close(); |
|
|
fromClientReader.close(); |
|
|