MqttSession class abstract
Class is used for managing MQTT session and publishing position data to MQTT broker. Referenced from NavigineSdk.
- Implemented types
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
MqttSessionListener listener) → void -
Method is used to add MqttSessionListener class element
which will notify about MQTT session connection state changes.
Note: Do not forget to remove listener if it is no longer needed!
listenerCorresponding MqttSessionListener class. -
connect(
String server, int port, String username, String password) → void -
Method is used to connect to MQTT broker and start publishing position data.
serverMQTT broker server hostname or IP address.portMQTT broker server port.usernameMQTT broker username for authentication.passwordMQTT broker password for authentication. -
disconnect(
) → void - Method is used to disconnect from MQTT broker and stop publishing position data.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
publish(
String topic, String message) → void -
Method is used to publish a custom message to a specified MQTT topic.
The message will be sent asynchronously and the result will be notified through
Note: The MQTT session must be connected before calling this method. Use connect method first.
MqttSessionListener callbacks (onMessagePublished for success, onError for failure).
topicMQTT topic to publish the message to. Can be any valid MQTT topic string.messageMessage content to publish. Can be any string (JSON, plain text, etc.). -
removeListener(
MqttSessionListener listener) → void -
Method is used for removing previously added MqttSessionListener class element.
listenerCorresponding MqttSessionListener class to remove. -
setSubTopic(
String subTopic) → void -
Method is used to set MQTT sub-topic for publishing position data.
The final topic will be "navigine/mobile/positions/" + subTopic + "/" + deviceId.
subTopicMQTT sub-topic for publishing position data. Must match pattern0-9a-zA-Z_-+ and cannot be empty. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited