Files
ClientApiPoC/Shared/SignalR/ClientTracker.cs
2026-03-13 10:23:47 +01:00

18 lines
642 B
C#

using System.Collections.Concurrent;
namespace ClientApiPoC.Shared.SignalR {
public class ClientTracker {
private ConcurrentDictionary<string, string> _knownClientIds = new();
public ICollection<string> 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 _);
}
}
}