Newer
Older
BlazorKafkaSignalR / src / BlazingPizza.Server / Kitchen / OrderPlacedEventNotificationHandler.cs
@Derek Comartin Derek Comartin on 1 Jun 2021 691 bytes Init
using System.Threading.Tasks;
using BlazingPizza.Events;
using DotNetCore.CAP;
using Microsoft.AspNetCore.SignalR;

namespace BlazingPizza.Server
{
    public class OrderPlacedEventNotificationHandler : ICapSubscribe
    {
        private readonly IHubContext<KitchenOrderHub> _hubContext;

        public OrderPlacedEventNotificationHandler(IHubContext<KitchenOrderHub> hubContext)
        {
            _hubContext = hubContext;
        }

        [CapSubscribe("orders", Group = nameof(OrderPlacedEventNotificationHandler))]
        public async Task Handle(OrderPlacedEvent orderPlacedEvent)
        {
            await _hubContext.Clients.All.SendAsync("OrderPlaced");
        }
    }
}