MqttSession class abstract

@ingroup navigine_dart_classes @ingroup navigine_dart_managers

@brief Class is used for managing MQTT session and publishing position data to MQTT broker.

Referenced from @see NavigineSdk "NavigineSdk".

Implemented types
Implementers

Constructors

MqttSession()

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
@brief Method is used to add @see MqttSessionListener "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! @param listener Сorresponding @see MqttSessionListener "MqttSessionListener" class.
connect(String server, int port, String username, String password) → void
@brief Method is used to connect to MQTT broker and start publishing position data. @param server MQTT broker server hostname or IP address. @param port MQTT broker server port. @param username MQTT broker username for authentication. @param password MQTT broker password for authentication.
disconnect() → void
@brief 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
@brief 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 @see MqttSessionListener "MqttSessionListener" callbacks (onMessagePublished for success, onError for failure). @note The MQTT session must be connected before calling this method. Use @see MqttSession::connect "connect" method first. @param topic MQTT topic to publish the message to. Can be any valid MQTT topic string. @param message Message content to publish. Can be any string (JSON, plain text, etc.).
removeListener(MqttSessionListener listener) → void
@brief Method is used for removing previously added @see MqttSessionListener "MqttSessionListener" class element. @param listener Сorresponding @see MqttSessionListener "MqttSessionListener" class to remove.
setSubTopic(String subTopic) → void
@brief Method is used to set MQTT sub-topic for publishing position data. The final topic will be "navigine/mobile/positions/" + subTopic + "/" + deviceId. @param subTopic MQTT sub-topic for publishing position data. Must match pattern 0-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