Files
BI/server/DongfangHydro.Dashboard.Api/Realtime/SignalRDashboardNotifier.cs
T

25 lines
991 B
C#

using DongfangHydro.Dashboard.Api.Contracts;
using Microsoft.AspNetCore.SignalR;
namespace DongfangHydro.Dashboard.Api.Realtime;
public sealed class SignalRDashboardNotifier(IHubContext<DashboardHub> hubContext)
: IDashboardNotifier
{
public async Task PublishUpdateAsync(
UpdateNodeProgressResultDto update,
DashboardOverviewDto overview,
CancellationToken cancellationToken)
{
var clients = hubContext.Clients.All;
await Task.WhenAll(
clients.SendAsync("nodeUpdated", update.Node, cancellationToken),
clients.SendAsync("orderUpdated", update.Order, cancellationToken),
clients.SendAsync("trendAppended", update.TrendPoint, cancellationToken),
clients.SendAsync("overviewUpdated", overview, cancellationToken),
update.RiskEvent is null
? Task.CompletedTask
: clients.SendAsync("riskEventCreated", update.RiskEvent, cancellationToken));
}
}