public async Task Handle(PrintJobCreatedNotification notification, CancellationToken cancellationToken) { PrintJob job; while ((job = await _printQueue.DequeueAsync(notification.PrinterId)) != null) { var clients = _hub.Clients.Group($"Printers:{notification.PrinterId}"); await clients.SendAsync("Print", job); } }
public async Task Hello(int terminalId) { var printerIds = await _db.Printers.Where(x => x.TerminalId == terminalId).Select(x => x.Id).ToListAsync(); foreach (var printerId in printerIds) { await Groups.AddToGroupAsync(Context.ConnectionId, $"Printers:{printerId}"); PrintJob job; while ((job = await _printQueue.DequeueAsync(printerId)) != null) { await Clients.Caller.SendAsync("Print", job); } } }