添加项目文件。
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace HardwareWeb.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录当前订阅视频帧的 SignalR 连接。
|
||||
/// 广播服务据此判断“是否有观看者”,没有观看者时不编码、不发送画面。
|
||||
/// </summary>
|
||||
public sealed class CameraViewerRegistry
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, byte> _viewers =
|
||||
new(StringComparer.Ordinal);
|
||||
|
||||
public int Count => _viewers.Count;
|
||||
|
||||
public bool HasViewers => !_viewers.IsEmpty;
|
||||
|
||||
public bool Add(string connectionId) => _viewers.TryAdd(connectionId, 0);
|
||||
|
||||
public bool Remove(string connectionId) =>
|
||||
_viewers.TryRemove(connectionId, out _);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user