March 2018
Beginner to intermediate
410 pages
10h 40m
English
When we have chosen the quality of service, we need to decide whether the content should be retained by the broker on the given topic. In our example, we choose not to. A new subscriber will be updated anyway if the sensor is connected. If the sensor is not connected, we don't want to give new subscribers obsolete sensor data.
The last parameter of the PUBLISH() method contains the actual payload of the packet we want to publish. Payloads in MQTT are always binary! There are no rules for how the content is encoded. We choose to encode our string using UTF-8:
this.mqttClient.PUBLISH( "Waher/MIOT/" + this.deviceId + "/Light", MqttQualityOfService.AtMostOnce, false, Encoding.UTF8.GetBytes(ValueStr)); this.PublishLastJson(); ...
Read now
Unlock full access