public MessagingProvider(MqttConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            _config = new MqttClientOptions
            {
                Host     = _config.Host,
                Port     = _config.Port,
                UserName = _config.UserName,
                Password = _config.Password
            };;
        }
Пример #2
0
        public MqttClient(
            MqttClientOptions config,
            string topicName)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (string.IsNullOrWhiteSpace(topicName))
            {
                throw new ArgumentException("Value cannot be empty.", nameof(topicName));
            }

            _config    = config;
            _topicName = topicName;

            _mqttFactory     = new MqttFactory();
            _innerMqttClient = _mqttFactory.CreateManagedMqttClient();
        }