sledgemapper/Sledgemapper.Api/Handlers/SendNewOverlayMessage.cs
Michele Scandura f12132009f
All checks were successful
continuous-integration/drone/push Build is passing
Send position and overlay
2021-09-17 12:37:02 +01:00

22 lines
771 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.SessionId.ToString()).NewOverlay(notification.Overlay);
}
}
}