using DXPBLL.Common; using DXPDAL.Common; using Microsoft.AspNetCore.SignalR; namespace DXPSL.Hubs; // Concrete implementation of the BLL-defined IDXPHubNotifier, wrapping // IHubContext — this is the one place in the whole module allowed to know // about SignalR, per CLAUDE.md's "BLL must never reference ASP.NET types" rule. Registered as a // Singleton in Program.cs/DXPModule.cs (IHubContext itself is singleton and thread-safe) — // mirrors IceImportSL.Hubs.IceImportRunNotifier exactly. public class DXPHubNotifier : IDXPHubNotifier { private readonly IHubContext _hubContext; private readonly ILogger _logger; public DXPHubNotifier(IHubContext hubContext, ILogger logger) { _hubContext = hubContext; _logger = logger; } public async Task NotifyAsync(DXPNotificationDTO notification, CancellationToken ct = default) { try { await _hubContext.Clients.Group(DXPHub.PartyGroup(notification.DxpPartyId)) .ReceiveNotification(notification); } catch (Exception ex) { _logger.LogWarning(ex, "DXPHubNotifier: failed to push {EventType} for DxpPartyId {DxpPartyId}", notification.EventType, notification.DxpPartyId); } } }