Ajout leave message
This commit is contained in:
parent
797744f92f
commit
d552b8d622
|
@ -26,8 +26,11 @@ namespace Galactic_Colors_Control_Server.Commands
|
||||||
{
|
{
|
||||||
soc.Shutdown(SocketShutdown.Both);
|
soc.Shutdown(SocketShutdown.Both);
|
||||||
Logger.Write("Client disconnected from " + Utilities.GetName(soc), Logger.logType.info);
|
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();
|
soc.Close();
|
||||||
Program.clients.Remove(soc);
|
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);
|
Logger.Write("Size: " + Program.clients.Count + "/" + Program.config.size, Logger.logType.debug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,9 +159,12 @@ namespace Galactic_Colors_Control_Server
|
||||||
catch (SocketException)
|
catch (SocketException)
|
||||||
{
|
{
|
||||||
Logger.Write("Client forcefully disconnected from " + Utilities.GetName(current), Logger.logType.info);
|
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);
|
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.
|
current.Close(); // Don't shutdown because the socket may be disposed and its disconnected anyway.
|
||||||
clients.Remove(current);
|
clients.Remove(current);
|
||||||
|
if (connected) { Utilities.Broadcast(username + " leave the server", Utilities.dataType.message); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue