Example #1
0
        public async void Subscribe(AbstractCommand command)
        {
            if (this.IsConnected)
            {
                await this._mqttClient.SubscribeAsync(((CommandDiscoveryConfigModel)command.GetAutoDiscoveryConfig()).Command_topic);
            }
            else
            {
                while (this.IsConnected == false)
                {
                    await Task.Delay(5500);
                }

                await this._mqttClient.SubscribeAsync(((CommandDiscoveryConfigModel)command.GetAutoDiscoveryConfig()).Command_topic);
            }

            Subscribers.Add(command);
        }