public MqttConnectionService(IConfiguration config, IServiceScopeFactory serviceScopeFactory, BrokerEvents brokerEvents) { _config = config; _serviceScopeFactory = serviceScopeFactory; _brokerEvents = brokerEvents; _clientSettings = new MqttClientSettings(); _zigbeeSettings = new Zigbee2mqttSettings(); config.GetSection(nameof(MqttClientSettings)).Bind(_clientSettings); config.GetSection(nameof(Zigbee2mqttSettings)).Bind(_zigbeeSettings); }
public MqttClientService(IManagedMqttClientOptions options, IHubContext <BrokerHub> hubContext, BrokerEvents brokerEvents, ZigbeeEvents zigbeeEvents, IServiceScopeFactory serviceScopeFactory, IConfiguration config) { _options = options; _hubContext = hubContext; _brokerEvents = brokerEvents; _zigbeeEvents = zigbeeEvents; _serviceScopeFactory = serviceScopeFactory; _clientSettings = new MqttClientSettings(); _zigbeeSettings = new Zigbee2mqttSettings(); config.GetSection(nameof(MqttClientSettings)).Bind(_clientSettings); config.GetSection(nameof(Zigbee2mqttSettings)).Bind(_zigbeeSettings); _mqttClient = new MqttFactory().CreateManagedMqttClient(); ConfigureMqttClient(); }