28 lines
972 B
C#
28 lines
972 B
C#
namespace Knot.Modules.Conversations.Infrastructure.SignalR;
|
|
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Knot.Contracts.Messaging.Application.Abstractions;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
public class MessageNotifier : IMessageNotifier
|
|
{
|
|
private readonly IHubContext<ChatHub> _hubContext;
|
|
|
|
public MessageNotifier(IHubContext<ChatHub> hubContext)
|
|
{
|
|
_hubContext = hubContext;
|
|
}
|
|
|
|
public Task NotifyNewMessageAsync(Guid chatId, object messagePayload, CancellationToken cancellationToken)
|
|
{
|
|
return _hubContext.Clients.Group(chatId.ToString()).SendAsync("new_message", messagePayload, cancellationToken);
|
|
}
|
|
|
|
public Task NotifyMessageUpdateAsync(Guid chatId, string updateType, object updatePayload, CancellationToken cancellationToken)
|
|
{
|
|
return _hubContext.Clients.Group(chatId.ToString()).SendAsync(updateType, updatePayload, cancellationToken);
|
|
}
|
|
}
|