+37
-37
@@ -1,37 +1,37 @@
|
||||
using IM_API.Domain.Events;
|
||||
using IM_API.Dtos;
|
||||
using IM_API.Hubs;
|
||||
using IM_API.Interface.Services;
|
||||
using IM_API.Models;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace IM_API.Application.EventHandlers.FriendAddHandler
|
||||
{
|
||||
public class FriendAddSignalRHandler : IConsumer<FriendAddEvent>
|
||||
{
|
||||
private readonly IHubContext<ChatHub> _chathub;
|
||||
public FriendAddSignalRHandler(IHubContext<ChatHub> chathub)
|
||||
{
|
||||
_chathub = chathub;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<FriendAddEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var usersList = new List<string> {
|
||||
@event.RequestUserId.ToString(), @event.ResponseUserId.ToString()
|
||||
};
|
||||
var res = new HubResponse<MessageBaseDto>("Event", new MessageBaseDto()
|
||||
{
|
||||
ChatType = ChatType.PRIVATE,
|
||||
Content = "您有新的好友关系已添加",
|
||||
//MsgId = @event.EventId.ToString(),
|
||||
ReceiverId = @event.ResponseUserId,
|
||||
SenderId = @event.RequestUserId,
|
||||
TimeStamp = DateTime.Now
|
||||
});
|
||||
await _chathub.Clients.Users(usersList).SendAsync("ReceiveMessage", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
using IM_API.Domain.Events;
|
||||
using IM_API.Dtos;
|
||||
using IM_API.Hubs;
|
||||
using IM_API.Interface.Services;
|
||||
using IM_API.Models;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace IM_API.Application.EventHandlers.FriendAddHandler
|
||||
{
|
||||
public class FriendAddSignalRHandler : IConsumer<FriendAddEvent>
|
||||
{
|
||||
private readonly IHubContext<ChatHub> _chathub;
|
||||
public FriendAddSignalRHandler(IHubContext<ChatHub> chathub)
|
||||
{
|
||||
_chathub = chathub;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<FriendAddEvent> context)
|
||||
{
|
||||
var @event = context.Message;
|
||||
var usersList = new List<string> {
|
||||
@event.RequestUserId.ToString(), @event.ResponseUserId.ToString()
|
||||
};
|
||||
var res = new HubResponse<MessageBaseDto>("Event", new MessageBaseDto()
|
||||
{
|
||||
ChatType = ChatType.PRIVATE,
|
||||
Content = "您有新的好友关系已添加",
|
||||
//MsgId = @event.EventId.ToString(),
|
||||
ReceiverId = @event.ResponseUserId,
|
||||
SenderId = @event.RequestUserId,
|
||||
TimeStamp = DateTime.Now
|
||||
});
|
||||
await _chathub.Clients.Users(usersList).SendAsync("ReceiveMessage", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user