using System.Collections.Concurrent; namespace ClientApiPoC.Shared.SignalR { public class ClientTracker { private ConcurrentDictionary _knownClientIds = new(); public ICollection CurrentClientIds => _knownClientIds.Values; public bool TryAddClientId(string clientId) { if (string.IsNullOrWhiteSpace(clientId)) throw new ArgumentNullException(nameof(clientId)); return _knownClientIds.TryAdd(clientId, clientId); } public bool TryRemoveClientId(string clientId) { return _knownClientIds.TryRemove(clientId, out _); } } }