예제 #1
0
 public MqttParcel(string topic, byte[] payload, QoS qos, bool retained)
 {
   this.topic = topic;
   this.payload = new MqttPayload(payload,0);
   this.qos = qos;
   this.retained = retained;
 }
예제 #2
0
 public MqttParcel(string topic, MqttPayload payload, QoS qos, bool retained )
 {
   this.topic = topic;
   this.payload = payload;
   this.qos = qos;
   this.retained = retained;
 }
예제 #3
0
 /// <summary>
 /// Constructs a PublishArrivedArgs object
 /// </summary>
 /// <param name="topic">Source of message</param>
 /// <param name="payload">Message body</param>
 /// <param name="retained">Whether or not the message is retained</param>
 public PublishArrivedArgs(string topic, MqttPayload payload, bool retained, QoS qos)
 {
   _topic = topic;
   _payload = payload;
   _retained = retained;
   _qos = qos;
 }
예제 #4
0
 public void Connect(string willTopic, QoS willQoS, MqttPayload willMsg, bool willRetain)
 {
     DoConnect(new MqttConnectMessage(
       _clientID, _username, _password, _keepAlive, willTopic, willMsg.TrimmedBuffer, willQoS, willRetain, false
     ));
 }
예제 #5
0
 public int Publish(string topic, MqttPayload payload, QoS qos, bool retained)
 {
     if (manager.IsConnected)
     {
         // Reset the PINGREQ timer as this publish will reset the server's counter
         if (keepAliveTimer != null)
         {
             int kmillis = 1000 * _keepAlive;
             keepAliveTimer.Change(kmillis, kmillis);
         }
         ushort messID = MessageID;
         manager.SendMessage(new MqttPublishMessage(messID, topic, payload.TrimmedBuffer, qos, retained));
         return messID;
     }
     else
     {
         throw new MqttNotConnectedException("You need to connect to a broker before trying to Publish");
     }
 }