29 lines
723 B
C#
29 lines
723 B
C#
using System.Collections.Concurrent;
|
|
using NATS.Server.Subscriptions;
|
|
|
|
namespace NATS.Server.Auth;
|
|
|
|
public sealed class Account : IDisposable
|
|
{
|
|
public const string GlobalAccountName = "$G";
|
|
|
|
public string Name { get; }
|
|
public SubList SubList { get; } = new();
|
|
public Permissions? DefaultPermissions { get; set; }
|
|
|
|
private readonly ConcurrentDictionary<ulong, byte> _clients = new();
|
|
|
|
public Account(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
public int ClientCount => _clients.Count;
|
|
|
|
public void AddClient(ulong clientId) => _clients[clientId] = 0;
|
|
|
|
public void RemoveClient(ulong clientId) => _clients.TryRemove(clientId, out _);
|
|
|
|
public void Dispose() => SubList.Dispose();
|
|
}
|