Exemple #1
0
 public ProcessingService(ILogger <ProcessingService> logger, ChannelReader <MqttApplicationMessage> channelReader, IHubContext <DataHub, IDataHub> hubContext, MqttReceiverService mqttReceiverService, HildebrandStateStore store)
 {
     Logger              = logger;
     ChannelReader       = channelReader;
     HubContext          = hubContext;
     MqttReceiverService = mqttReceiverService;
     Store = store;
 }
Exemple #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await MqttReceiverService.StartAsync(stoppingToken);

            await foreach (var message in ChannelReader.ReadAllAsync(stoppingToken))
            {
                try
                {
                    await HandleMessageAsync(message);
                }
                catch (Exception ex)
                {
                    Logger.LogWarning(ex, "Error handling payload: {Exception}", ex.Message);
                }
            }
        }