Ejemplo n.º 1
0
        /// Create MQTT router and MQTT client
        public Mqtt(string IP, MqttConfiguration config, MqttClientCredentials creds = null)
        {
            var client = MqttClient.CreateAsync(IP, config);

            client.Wait();
            Client = client.Result;

            Task <SessionState> conn;

            if (creds == null)
            {
                conn = Client.ConnectAsync();
            }
            else
            {
                conn = Client.ConnectAsync(creds);
            }
            conn.Wait();

            On = new MqttRouter(Client);
        }
Ejemplo n.º 2
0
 public Mqtt(string v, MqttClientCredentials creds, IMqttClient client)
 {
     this.Client = client;
     On          = new MqttRouter(client);
 }