sledgemapper/Sledgemapper.Api/Handlers/SendNewOverlayMessage.cs
2020-11-22 21:41:22 +00:00

22 lines
762 B
C#

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