using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
namespace ZB.MOM.WW.MxGateway.Server.Dashboard.Hubs;
///
/// SignalR hub that pushes alarm-feed messages from the gateway's
/// central alarm monitor. Connected clients auto-join
/// on connect and receive every
/// AlarmFeedMessage the monitor emits.
///
///
/// The feed is galaxy-wide: the alarm monitor is gateway-central and its messages carry no
/// session provenance, so the per-session tag ACL that scopes EventsHub has nothing
/// to intersect here and is deliberately not applied — every authenticated Viewer sees the whole
/// subscription expression's alarm metadata. What is tightened instead is the entry gate:
/// rather than the
/// the other hubs use, so the
/// read-only environment bypasses (Authentication:Mode=Disabled, anonymous localhost) no
/// longer receive the feed. The /alarms page carries the same policy — the two readers of
/// one monitor must not disagree about who may see it.
///
[Authorize(Policy = DashboardAuthenticationDefaults.AlarmsPolicy)]
public sealed class AlarmsHub : Hub
{
public const string AllAlarmsGroup = "__alarms__";
/// Method name used to push AlarmFeedMessage values to clients.
public const string AlarmMessage = "AlarmFeed";
///
public override async Task OnConnectedAsync()
{
await Groups.AddToGroupAsync(Context.ConnectionId, AllAlarmsGroup).ConfigureAwait(false);
await base.OnConnectedAsync().ConfigureAwait(false);
}
}