using Microsoft.AspNetCore.SignalR; using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions; using Ordering.SignalrHub.IntegrationEvents.Events; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Ordering.SignalrHub.IntegrationEvents.EventHandling { public class OrderStatusChangedToShippedIntegrationEventHandler : IIntegrationEventHandler { private readonly IHubContext _hubContext; public OrderStatusChangedToShippedIntegrationEventHandler(IHubContext hubContext) { _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); } public async Task Handle(OrderStatusChangedToShippedIntegrationEvent @event) { await _hubContext.Clients .Group(@event.BuyerName) .SendAsync("UpdatedOrderState", new { OrderId = @event.OrderId, Status = @event.OrderStatus }); } } }