publish method
Publishes state information.
For more information, see HTTP Protocol in the AWS IoT Developer Guide.
May throw InternalFailureException. May throw InvalidRequestException. May throw UnauthorizedException. May throw MethodNotAllowedException.
Parameter topic
:
The name of the MQTT topic.
Parameter payload
:
The state information, in JSON format.
Parameter qos
:
The Quality of Service (QoS) level.
Implementation
Future<void> publish({
required String topic,
Uint8List? payload,
int? qos,
}) async {
ArgumentError.checkNotNull(topic, 'topic');
_s.validateNumRange(
'qos',
qos,
0,
1,
);
final $query = <String, List<String>>{
if (qos != null) 'qos': [qos.toString()],
};
await _protocol.send(
payload: payload,
method: 'POST',
requestUri: '/topics/${Uri.encodeComponent(topic)}',
queryParams: $query,
exceptionFnMap: _exceptionFns,
);
}