Try catcch handle socket and disconnect in listen
This commit is contained in:
parent
7bbba0c691
commit
69ff9bb47d
|
@ -25,13 +25,17 @@ public class Server {
|
||||||
|
|
||||||
Logger.Warn("ok");
|
Logger.Warn("ok");
|
||||||
|
|
||||||
if (Clients.Count > Constants.MaxClients) {
|
try {
|
||||||
Logger.Warn("Turned away client due to max clients");
|
if (Clients.Count > Constants.MaxClients) {
|
||||||
await socket.DisconnectAsync(false);
|
Logger.Warn("Turned away client due to max clients");
|
||||||
continue;
|
await socket.DisconnectAsync(false);
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
HandleSocket(socket);
|
HandleSocket(socket);
|
||||||
|
} catch {
|
||||||
|
// super ignore this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +113,7 @@ public class Server {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ConnectionTypes.Reconnecting: {
|
case ConnectionTypes.Reconnecting: {
|
||||||
|
client.Id = header.Id;
|
||||||
if (FindExistingClient(header.Id) is { } newClient) {
|
if (FindExistingClient(header.Id) is { } newClient) {
|
||||||
if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}");
|
if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}");
|
||||||
newClient.Socket = client.Socket;
|
newClient.Socket = client.Socket;
|
||||||
|
|
Loading…
Reference in New Issue