/// <summary> /// Remove a client when it disconnects /// </summary> /// <param name="clientSocket"></param> private static void HandleDisconnect(WebSocket clientSocket) { AuthClient temp = null; if (AllClients.TryRemove(clientSocket.GetHashCode().ToString(), out temp)) { Console.WriteLine("Disconnection from " + clientSocket.RemoteEndpoint); var userCount = AllClients.Count; var extra = userCount < 1 ? "s" : string.Empty; UlteriusTray.ShowMessage($"There are now {userCount} user{extra} connected.", "A user disconnected!"); } }
private static void HandleDisconnect(WebSocket clientSocket) { foreach (var client in AllClients) { if (client.Value.Client != clientSocket) { continue; } AuthClient temp = null; ApiController temp2 = null; AllClients.TryRemove(client.Key, out temp); ApiControllers.TryRemove(client.Key, out temp2); Console.WriteLine("Disconnection from " + clientSocket.RemoteEndpoint); Console.WriteLine(ApiControllers.Count); } }