using IM_API.Domain.Events; using IM_API.Dtos; using IM_API.Hubs; using IM_API.VOs.Group; using MassTransit; using Microsoft.AspNetCore.SignalR; namespace IM_API.Application.EventHandlers.GroupInviteActionUpdateHandler { public class SignalRHandler : IConsumer { private IHubContext _hub; public SignalRHandler(IHubContext hub) { _hub = hub; } public async Task Consume(ConsumeContext context) { var @event = context.Message; var msg = new HubResponse("Event", new GroupInviteActionUpdateVo { Action = @event.Action, GroupId = @event.GroupId, InvitedUserId = @event.UserId, InviteUserId = @event.InviteUserId, InviteId = @event.InviteId }); await _hub.Clients.Users([@event.UserId.ToString(), @event.InviteUserId.ToString()]) .SendAsync("ReceiveMessage",msg); } } }