Files
meezi/src/Meezi.API/Services/KdsNotifier.cs
T

26 lines
1.1 KiB
C#
Raw Normal View History

2026-05-27 21:33:48 +03:30
using Microsoft.AspNetCore.SignalR;
using Meezi.API.Hubs;
using Meezi.API.Models.Orders;
using Meezi.Core.Enums;
namespace Meezi.API.Services;
public class KdsNotifier : IKdsNotifier
{
private readonly IHubContext<KdsHub> _hubContext;
public KdsNotifier(IHubContext<KdsHub> hubContext)
{
_hubContext = hubContext;
}
public Task NotifyOrderCreatedAsync(string cafeId, LiveOrderDto order, CancellationToken cancellationToken = default) =>
_hubContext.Clients.Group(KdsHub.GroupName(cafeId)).SendAsync("OrderCreated", order, cancellationToken);
public Task NotifyOrderStatusChangedAsync(string cafeId, string orderId, OrderStatus status, CancellationToken cancellationToken = default) =>
_hubContext.Clients.Group(KdsHub.GroupName(cafeId)).SendAsync("OrderStatusChanged", new { orderId, status }, cancellationToken);
public Task NotifyTableStatusChangedAsync(string cafeId, CancellationToken cancellationToken = default) =>
_hubContext.Clients.Group(KdsHub.GroupName(cafeId)).SendAsync("TableStatusChanged", null, cancellationToken);
}