subscribe method

Subscription? subscribe(
  1. String topic,
  2. MqttQos qosLevel
)

Initiates a single topic subscription request to the broker. The topic to subscribe to. The qos level the message was published at. Returns the subscription or null on failure.

Implementation

Subscription? subscribe(String topic, MqttQos qosLevel) {
  if (connectionStatus!.state != MqttConnectionState.connected) {
    throw ConnectionException(connectionHandler?.connectionStatus.state);
  }
  return subscriptionsManager!.registerSubscription(topic, qosLevel);
}