Try catcch handle socket and disconnect in listen

This commit is contained in:
Sanae 2022-02-11 10:16:19 -06:00
parent 7bbba0c691
commit 69ff9bb47d
1 changed files with 11 additions and 6 deletions

View File

@ -25,13 +25,17 @@ public class Server {
Logger.Warn("ok");
if (Clients.Count > Constants.MaxClients) {
Logger.Warn("Turned away client due to max clients");
await socket.DisconnectAsync(false);
continue;
}
try {
if (Clients.Count > Constants.MaxClients) {
Logger.Warn("Turned away client due to max clients");
await socket.DisconnectAsync(false);
continue;
}
HandleSocket(socket);
HandleSocket(socket);
} catch {
// super ignore this
}
}
}
@ -109,6 +113,7 @@ public class Server {
break;
}
case 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}");
newClient.Socket = client.Socket;