using Microsoft.AspNetCore.Http; using System.Threading.Tasks; using New_College.Common.LogHelper; using New_College.Hubs; using Microsoft.AspNetCore.SignalR; using New_College.Common; namespace New_College.Middlewares { /// /// 中间件 /// SignalR发送数据 /// public class SignalRSendMildd { /// /// /// private readonly RequestDelegate _next; private readonly IHubContext _hubContext; /// /// /// /// /// public SignalRSendMildd(RequestDelegate next, IHubContext hubContext) { _next = next; _hubContext = hubContext; } public async Task InvokeAsync(HttpContext context) { if (Appsettings.app("Middleware", "SignalR", "Enabled").ObjToBool()) { await _hubContext.Clients.All.SendAsync("ReceiveUpdate", LogLock.GetLogData()); } await _next(context); } } }