using Furion.EventBus; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Myshipping.Core { public class MessagePushSubscriber : IEventSubscriber { private readonly IHubContext _chatHubContext; private readonly ILogger _logger; public MessagePushSubscriber(IHubContext chatHubContext, ILogger logger) { this._chatHubContext = chatHubContext; _logger = logger; } [EventSubscribe("Message:NotifyReceiveNew")] public async Task NotifyReceiveNew(EventHandlerExecutingContext context) { _logger.LogInformation($"收到推送接收到新消息的订阅消息"); await _chatHubContext.Clients.All.NotifyReceiveNewMessage(); } } }