using Microsoft.AspNetCore.Http; using System.Threading.Tasks; using Admin.Core.Common; using Microsoft.AspNetCore.SignalR; namespace Admin.Core.Extensions { /// /// 中间件 /// 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); } } }