Esempio n. 1
0
        private async Task <bool> StartMqtt()
        {
            Console.WriteLine($"Trying to connect to {_masterAddress} with user {_user} and clientId {_nodeId}");
            try
            {
                foreach (var factory in _factories)
                {
                    var connection = new MqttConnection(_logger, _masterAddress, _nodeId, _user, _password, factory, _serviceProvider);
                    if (!await connection.Start())
                    {
                        return(false);
                    }

                    _connections.Add(connection);
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Could not start mqtt connection");
                return(false);
            }

            return(true);
        }
 public MqttDisconnectedHandler(MqttConnection mqttConnection)
 {
     _mqttConnection = mqttConnection;
 }
Esempio n. 3
0
 public MqttMessageHandlers(ILogger logger, MqttConnection connection)
 {
     _connection = connection;
     Logger      = logger;
 }