Exemplo n.º 1
0
 public string Subscribe(string messgeTopic)
 {
     if (AppMQTTClient != null)
     {
         ushort msgId = AppMQTTClient.Subscribe(new string[] { messgeTopic },
                                                new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }
                                                );
         //Logger.Info(string.Format("Subscription to topic {0}", messgeTopic));
     }
     return("Success");
 }
Exemplo n.º 2
0
        private void DefinedMQTTCommunicationEvents()
        {
            AppMQTTClient.MqttMsgPublished       += client_MqttMsgPublished;       //publish
            AppMQTTClient.MqttMsgSubscribed      += client_MqttMsgSubscribed;      //subscribe confirmation
            AppMQTTClient.MqttMsgUnsubscribed    += client_MqttMsgUnsubscribed;
            AppMQTTClient.MqttMsgPublishReceived += client_MqttMsgPublishReceived; //received message.
            AppMQTTClient.ConnectionClosed       += client_ConnectionClosed;

            ushort submsgId = AppMQTTClient.Subscribe(new string[] { "shhello", "sh/configuration", "sh/command", "sh/feedback/#" },
                                                      new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE,
                                                                   MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });
        }