using Microsoft.AspNetCore.SignalR; using SkillManagementBLL.Common; namespace SkillManagementSL.EndPoints.Hubs; // Concrete implementation of the BLL-defined ISkillHubNotifier, wrapping // IHubContext — this is the one place in this module allowed to know // about SignalR, per CLAUDE.md's "BLL must never reference ASP.NET types" rule. Registered as a // Singleton in SkillManagementModule.cs (IHubContext itself is singleton and thread-safe). // Mirrors WiSL.EndPoints.Hubs.WiHubNotifier exactly. public class SkillHubNotifier(IHubContext hubContext, ILogger logger) : ISkillHubNotifier { public async Task NotifyProfileChangedAsync(int employeeId, int skillId, int clientId, CancellationToken ct = default) { try { await hubContext.Clients.Group(SkillHub.EmployeeGroup(employeeId)) .ReceiveProfileChanged(employeeId, skillId); await hubContext.Clients.Group(SkillHub.MatrixGroup(clientId)) .ReceiveMatrixChanged(clientId); } catch (Exception ex) { logger.LogWarning(ex, "SkillHubNotifier: failed to push profile change for EmployeeId {EmployeeId}", employeeId); } } }