0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 12:45:18 +00:00

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

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;