publishMessage method
Publishes a message to the message broker. Returns The message identifer assigned to the message. Raises InvalidTopicException if the topic supplied violates the MQTT topic format rules.
Implementation
int publishMessage(
String topic, MqttQos qualityOfService, typed.Uint8Buffer data,
{bool retain = false}) {
if (connectionHandler?.connectionStatus.state !=
MqttConnectionState.connected) {
throw ConnectionException(connectionHandler?.connectionStatus.state);
}
try {
final pubTopic = PublicationTopic(topic);
return publishingManager!
.publish(pubTopic, qualityOfService, data, retain);
} on Exception catch (e) {
throw InvalidTopicException(e.toString(), topic);
}
}