using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.SignalR; namespace ZB.MOM.WW.MxGateway.Server.Dashboard.Hubs; /// /// SignalR hub that pushes a fresh on every /// snapshot refresh. New connections receive the current snapshot /// immediately via ; subsequent refreshes are /// broadcast by . /// [Authorize(Policy = DashboardAuthenticationDefaults.HubClientsPolicy)] public sealed class DashboardSnapshotHub(IDashboardSnapshotService snapshotService) : Hub { /// Method name used to push snapshot updates to clients. public const string SnapshotMessage = "SnapshotUpdated"; /// public override async Task OnConnectedAsync() { await Clients.Caller.SendAsync(SnapshotMessage, snapshotService.GetSnapshot()).ConfigureAwait(false); await base.OnConnectedAsync().ConfigureAwait(false); } }