sledgemapper/Sledgemapper.Api/Handlers/SendNewTileMessage.cs
Michele Scandura 333c6c4046
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
stability improvements
2021-09-22 16:16:46 +01:00

23 lines
773 B
C#

using MediatR;
using Microsoft.AspNetCore.SignalR;
using Sledgemapper.Api.Notifications;
using System.Threading;
using System.Threading.Tasks;
using Sledgemapper.Api.Hubs;
using Sledgemapper.Shared.Clients;
namespace Sledgemapper.Api.Handlers
{
public class SendNewTileMessage : INotificationHandler<NewTileNotification>
{
private readonly IHubContext<SledgemapperHub, ISledgemapperClient> _hub;
public SendNewTileMessage(IHubContext<SledgemapperHub, ISledgemapperClient> hub) => _hub = hub;
public async Task Handle(NewTileNotification notification, CancellationToken cancellationToken)
{
await _hub.Clients.Groups(notification.Session.SessionId.ToString()).NewTile(notification.Tile);
}
}
}