first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using F9WebAiTest.Api.Hubs;
|
||||
using F9WebAiTest.Application.Services;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace F9WebAiTest.Api.Services;
|
||||
|
||||
/// <summary>
|
||||
/// 业务状态变更事件的 SignalR 推送处理器。
|
||||
/// 业务服务发布 BusinessChangedEvent 后,推送给所有在线客户端,
|
||||
/// 各端监听 "BusinessChanged" 后刷新已打开的相关页面,实现多端实时同步。
|
||||
/// </summary>
|
||||
public class BusinessChangedEventHandler : INotificationHandler<BusinessChangedEvent>
|
||||
{
|
||||
private readonly IHubContext<NotificationHub> _hubContext;
|
||||
|
||||
public BusinessChangedEventHandler(IHubContext<NotificationHub> hubContext)
|
||||
=> _hubContext = hubContext;
|
||||
|
||||
public Task Handle(BusinessChangedEvent e, CancellationToken ct)
|
||||
=> _hubContext.Clients.All.SendAsync("BusinessChanged", e, ct);
|
||||
}
|
||||
Reference in New Issue
Block a user