+24
-24
@@ -1,24 +1,24 @@
|
||||
using IM_API.Domain.Events;
|
||||
using IM_API.Interface.Services;
|
||||
using MassTransit;
|
||||
|
||||
namespace IM_API.Application.EventHandlers.GroupInviteActionUpdateHandler
|
||||
{
|
||||
public class RequestDbHandler : IConsumer<GroupInviteActionUpdateEvent>
|
||||
{
|
||||
private readonly IGroupService _groupService;
|
||||
public RequestDbHandler(IGroupService groupService)
|
||||
{
|
||||
_groupService = groupService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<GroupInviteActionUpdateEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
if(@event.Action == Models.GroupInviteState.Passed)
|
||||
{
|
||||
await _groupService.MakeGroupRequestAsync(@event.UserId, @event.InviteUserId,@event.GroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using IM_API.Domain.Events;
|
||||
using IM_API.Interface.Services;
|
||||
using MassTransit;
|
||||
|
||||
namespace IM_API.Application.EventHandlers.GroupInviteActionUpdateHandler
|
||||
{
|
||||
public class RequestDbHandler : IConsumer<GroupInviteActionUpdateEvent>
|
||||
{
|
||||
private readonly IGroupService _groupService;
|
||||
public RequestDbHandler(IGroupService groupService)
|
||||
{
|
||||
_groupService = groupService;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<GroupInviteActionUpdateEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
if(@event.Action == Models.GroupInviteState.Passed)
|
||||
{
|
||||
await _groupService.MakeGroupRequestAsync(@event.UserId, @event.InviteUserId,@event.GroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+34
-34
@@ -1,34 +1,34 @@
|
||||
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<GroupInviteActionUpdateEvent>
|
||||
{
|
||||
private IHubContext<ChatHub> _hub;
|
||||
public SignalRHandler(IHubContext<ChatHub> hub)
|
||||
{
|
||||
_hub = hub;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<GroupInviteActionUpdateEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var msg = new HubResponse<GroupInviteActionUpdateVo>("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);
|
||||
}
|
||||
}
|
||||
}
|
||||
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<GroupInviteActionUpdateEvent>
|
||||
{
|
||||
private IHubContext<ChatHub> _hub;
|
||||
public SignalRHandler(IHubContext<ChatHub> hub)
|
||||
{
|
||||
_hub = hub;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<GroupInviteActionUpdateEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var msg = new HubResponse<GroupInviteActionUpdateVo>("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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user