subscribe method

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

Initiates a topic subscription request to the connected broker with a strongly typed data processor callback. The topic to subscribe to. The maximum Qos level. Returns the subscription or null on failure

Implementation

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