sledgemapper/Sledgemapper.Api/Handlers/SendNewLineMessage.cs
2021-01-14 23:34:24 +00:00

22 lines
744 B
C#

using MediatR;
using Microsoft.AspNetCore.SignalR;
using Sledgemapper.Api.Notifications;
using Sledgemapper.Clients;
using System.Threading;
using System.Threading.Tasks;
using Sledgemapper.Api.Hubs;
namespace Sledgemapper.Api.Handlers
{
public class SendNewLineMessage : INotificationHandler<NewLineNotification>
{
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
public SendNewLineMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
public async Task Handle(NewLineNotification notification, CancellationToken cancellationToken)
{
await _hub.Clients.Groups(notification.Session.SessionName).NewLine(notification.Line);
}
}
}