diff --git a/Server/Program.cs b/Server/Program.cs index ca8bc2f..6ef1dc8 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -20,7 +20,7 @@ server.ClientJoined += (c, _) => { c.Metadata["speedrun"] = false; foreach (Client client in server.Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket")).ToArray()) { try { - Task.WaitAll(c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client)); + c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client).Wait(); } catch { // lol who gives a fuck diff --git a/Server/Server.cs b/Server/Server.cs index cd70e8b..7857409 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -180,7 +180,10 @@ public class Server { case ConnectPacket.ConnectionTypes.FirstConnection: { firstConn = true; if (FindExistingClient(header.Id) is { } newClient) { - if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}"); + if (newClient.Connected) { + newClient.Logger.Info($"Disconnecting already connected client {newClient.Socket?.RemoteEndPoint} for {client.Socket?.RemoteEndPoint}"); + newClient.Dispose(); + } newClient.Socket = client.Socket; client = newClient; } @@ -190,7 +193,10 @@ public class Server { case ConnectPacket.ConnectionTypes.Reconnecting: { client.Id = header.Id; if (FindExistingClient(header.Id) is { } newClient) { - if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}"); + if (newClient.Connected) { + newClient.Logger.Info($"Disconnecting already connected client {newClient.Socket?.RemoteEndPoint} for {client.Socket?.RemoteEndPoint}"); + newClient.Dispose(); + } newClient.Socket = client.Socket; client = newClient; } else {