Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created June 16, 2021 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/7d4bae55714b36c3a6bc0331ca9288c7 to your computer and use it in GitHub Desktop.
Save dcomartin/7d4bae55714b36c3a6bc0331ca9288c7 to your computer and use it in GitHub Desktop.
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