diff --git a/Server/Server.cs b/Server/Server.cs index 87cca84..6fcb903 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -308,6 +308,8 @@ public class Server { disconnect: Logger.Info($"Client {socket.RemoteEndPoint} ({client.Name}/{client.Id}) disconnected from the server"); + close: + bool wasConnected = client.Connected; // Clients.Remove(client) client.Connected = false; try { @@ -316,8 +318,10 @@ public class Server { catch { /*lol*/ } #pragma warning disable CS4014 - Task.Run(() => Broadcast(new DisconnectPacket(), client)) - .ContinueWith(x => { if (x.Exception != null) { Logger.Error(x.Exception.ToString()); } }); + if (wasConnected) { + Task.Run(() => Broadcast(new DisconnectPacket(), client)) + .ContinueWith(x => { if (x.Exception != null) { Logger.Error(x.Exception.ToString()); } }); + } #pragma warning restore CS4014 }