From d552b8d6229dcfe6b13b97ffc1c74614596f6281 Mon Sep 17 00:00:00 2001 From: sheychen Date: Sun, 16 Oct 2016 23:18:34 +0200 Subject: [PATCH] Ajout leave message --- Galactic Colors Control Server/Commands/ExitCommand.cs | 3 +++ Galactic Colors Control Server/Program.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Galactic Colors Control Server/Commands/ExitCommand.cs b/Galactic Colors Control Server/Commands/ExitCommand.cs index 1066302..55be0bb 100644 --- a/Galactic Colors Control Server/Commands/ExitCommand.cs +++ b/Galactic Colors Control Server/Commands/ExitCommand.cs @@ -26,8 +26,11 @@ namespace Galactic_Colors_Control_Server.Commands { soc.Shutdown(SocketShutdown.Both); Logger.Write("Client disconnected from " + Utilities.GetName(soc), Logger.logType.info); + string username = Utilities.GetName(soc); + bool connected = Program.clients[soc].status != -1; soc.Close(); Program.clients.Remove(soc); + if (connected) { Utilities.Broadcast(username + " leave the server", Utilities.dataType.message); } Logger.Write("Size: " + Program.clients.Count + "/" + Program.config.size, Logger.logType.debug); } } diff --git a/Galactic Colors Control Server/Program.cs b/Galactic Colors Control Server/Program.cs index 9b77f51..d8ba8fd 100644 --- a/Galactic Colors Control Server/Program.cs +++ b/Galactic Colors Control Server/Program.cs @@ -159,9 +159,12 @@ namespace Galactic_Colors_Control_Server catch (SocketException) { Logger.Write("Client forcefully disconnected from " + Utilities.GetName(current), Logger.logType.info); + string username = Utilities.GetName(current); + bool connected = Program.clients[current].status != -1; Logger.Write("Size: " + clients.Count + "/" + config.size, Logger.logType.debug); current.Close(); // Don't shutdown because the socket may be disposed and its disconnected anyway. clients.Remove(current); + if (connected) { Utilities.Broadcast(username + " leave the server", Utilities.dataType.message); } return; }