public void AddClient(NClient client) { lock (clients) { clients.Add(client); if (enable_ip) { var ip = AllocateIp(); client.Ip = new IPAddress((long)ip); ipmap.Add(ip, client); } } Logger.info($"added: {client}"); client.WhenDisconnected.GetAwaiter().OnCompleted(() => RemoveClient(client)); }
private void RemoveClient(NClient client) { bool success; lock (clients) { success = clients.Remove(client); if (success && enable_ip) { ipmap.Remove((uint)client.Ip.Address); } } if (success) { Logger.info($"removed: {client}"); } else { Logger.warning($"tried to remove a client that not found: {client}"); } }