sendMessage method
Sends a message to the broker through the current connection.
Implementation
@override
void sendMessage(MqttMessage? message) {
MqttLogger.log('MqttConnectionHandlerBase::sendMessage - ', message);
if ((connectionStatus.state == MqttConnectionState.connected) ||
(connectionStatus.state == MqttConnectionState.connecting)) {
final buff = typed.Uint8Buffer();
final stream = MqttByteBuffer(buff);
message!.writeTo(stream);
stream.seek(0);
connection.send(stream);
// Let any registered people know we're doing a message.
for (final callback in sentMessageCallbacks) {
callback(message);
}
} else {
MqttLogger.log('MqttConnectionHandlerBase::sendMessage - not connected');
}
}