static SmsRestApi() { string connectionString = MQTT_URL; string username = MQTT_USER; string password = MQTT_PASSWORD; var clientId = MQTTManager.BuildClientId(); if (smsMqttManager == null) { Console.WriteLine("Open MQTT"); smsMqttManager = new MQTTManager(connectionString, clientId, username, password); smsMqttManager.Start(channel); smsMqttManager.Publish(channel, $"@@@ New SMS rest api instance running on {Environment.MachineName} {Environment.UserDomainName} {Environment.UserName}"); } }
static TodoRestApi() { string connectionString = "tcp://m15.cloudmqtt.com:10989"; string username = MQTT_USER; string password = MQTT_PASSWORD; var clientId = MQTTManager.BuildClientId(); if (mqttManager == null) { Console.WriteLine("Open MQTT"); mqttManager = new MQTTManager(connectionString, clientId, username, password); mqttManager.Start(channel); mqttManager.Publish(channel, $"New todo rest api instance running on {Environment.MachineName} {Environment.UserDomainName} {Environment.UserName}"); } }
static void Main(string[] args) { string connectionString = "tcp://m15.cloudmqtt.com:10989"; string username = "******"; string password = "******"; const string channel = "/frederictorres/iotdashboard"; var clientId = MQTTManager.BuildClientId(); Console.WriteLine($"Starting mqttManager Console, clientId:{clientId}"); using (var mqttManager = new MQTTManager(connectionString, clientId, username, password)) { mqttManager.NotificationEvent += MqttManager_NotificationEvent; mqttManager.MessageArrived += MqttManager_MessageArrived; mqttManager.Start(channel); mqttManager.Subscribe(channel); while (true) { Console.WriteLine("Q)uit, S)end, C)lear"); var k = Console.ReadKey(true); if (k.Key == ConsoleKey.Q) { break; } if (k.Key == ConsoleKey.C) { Console.Clear(); } if (k.Key == ConsoleKey.S) { mqttManager.Publish(channel, $"[{Environment.MachineName}, {Environment.TickCount}]Working..."); } } } }