Initial commit.
This commit is contained in:
18
Shared/SignalR/ClientTracker.cs
Normal file
18
Shared/SignalR/ClientTracker.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
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 _);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user