publish method

  1. @override
Future<void> publish(
  1. RawMessage message
)
override

Sends message to the broker.

For QoS 0, completes once the message is sent. For QoS 1 and 2, completes only when the broker has confirmed it, so a completed future means the broker has the message.

Throws a ConnectionException if not connected, or if the connection ends before the broker confirms a QoS 1 or 2 message. The message may still have reached the broker in that case (QoS 1 means "at least once"), so sending it again can deliver it twice.

Implementation

@override
Future<void> publish(RawMessage message) async {
  _checkConnected();
  checkTopicName(message.topic);
  broker._publish(message);
}