1
0
Fork 0

Ajout leave message

This commit is contained in:
sheychen 2016-10-16 23:18:34 +02:00
parent 797744f92f
commit d552b8d622
2 changed files with 6 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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;
}