18 lines
642 B
C#
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 _);
|
|
}
|
|
}
|
|
} |