mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-22 03:05:16 +00:00
Try catcch handle socket and disconnect in listen
This commit is contained in:
parent
7bbba0c691
commit
69ff9bb47d
1 changed files with 11 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue