コード例 #1
0
        public BackgroundMqttClientHostedService(
            IMosquittoClientService client,
            ILogger <BackgroundMqttClientHostedService> logger,
            IMosquittoBrokerService service,
            IMosquittoBrokerPidAccessor accessor,
            IMosquittoBrokerPluginPidService pluginService,
            IHostEnvironment env,
            IConfiguration config)
        {
            _client        = client;
            _logger        = logger;
            _service       = service;
            _accessor      = accessor;
            _pluginService = pluginService;
            _env           = env;

            // Mosquitto handles around 50 more messages/s, 10 ms default is mostly safe enough
            var interval = config.GetSection("SMEIoT")?.GetValue <int>("MosquittoBackgroundClientRunloopInterval");

            if (interval.HasValue && interval.Value > 0)
            {
                _delay = interval.Value;
            }
            else
            {
                throw new InvalidOperationException("SMEIoT__MosquittoBackgroundClientRunloopInterval must be set to a positive milliseconds.");
            }
        }
コード例 #2
0
 public MosquittoBrokerService(
     IClock clock,
     ILogger <MosquittoBrokerService> logger,
     IMosquittoBrokerPidAccessor accessor,
     IMosquittoBrokerPluginPidService pluginService)
 {
     _clock         = clock;
     _logger        = logger;
     _accessor      = accessor;
     _pluginService = pluginService;
 }