Skip to content

Instantly share code, notes, and snippets.

@dcomartin

dcomartin/Consumer.cs Secret

Created Jun 16, 2021
Embed
What would you like to do?
public class CustomerOrderEventNotificationHandler : ICapSubscribe
{
private readonly IHubContext<CustomerOrderHub> _hubContext;
public CustomerOrderEventNotificationHandler(IHubContext<CustomerOrderHub> hubContext)
{
_hubContext = hubContext;
}
[CapSubscribe(nameof(OrderBeingPreparedEvent), Group = nameof(CustomerOrderEventNotificationHandler) + ":" + nameof(OrderBeingPreparedEvent))]
public async Task Handle(OrderBeingPreparedEvent orderBeingPreparedEvent)
{
await _hubContext.Clients.Group(orderBeingPreparedEvent.OrderId.ToString()).SendAsync("OrderBeingPrepared");
}
[CapSubscribe(nameof(OrderPickedUpForDeliveryEvent), Group = nameof(CustomerOrderEventNotificationHandler) + ":" + nameof(OrderPickedUpForDeliveryEvent))]
public async Task Handle(OrderPickedUpForDeliveryEvent orderPickedUpForDeliveryEvent)
{
await _hubContext.Clients.Group(orderPickedUpForDeliveryEvent.OrderId.ToString()).SendAsync("OrderPickedUpForDelivery");
}
[CapSubscribe(nameof(OrderDeliveredEvent), Group = nameof(CustomerOrderEventNotificationHandler) + ":" + nameof(OrderDeliveredEvent))]
public async Task Handle(OrderDeliveredEvent orderDeliveredEvent)
{
await _hubContext.Clients.Group(orderDeliveredEvent.OrderId.ToString()).SendAsync("OrderDelivered");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment