Class is used for managing MQTT session and publishing position data to MQTT broker. More...
#include <com/navigine/idl/objc/NCMqttSession.h>
Inherits NSObject.
Instance Methods | |
| (void) | - connect:port:username:password: |
| Method is used to connect to MQTT broker and start publishing position data. | |
| (void) | - setSubTopic: |
| Method is used to set MQTT sub-topic for publishing position data. The final topic will be "navigine/mobile/positions/" + subTopic + "/" + deviceId. | |
| (void) | - addListener: |
| Method is used to add MqttSessionListener class element which will notify about MQTT session connection state changes. | |
| (void) | - removeListener: |
| Method is used for removing previously added MqttSessionListener class element. | |
| (void) | - disconnect |
| Method is used to disconnect from MQTT broker and stop publishing position data. | |
| (void) | - publish:message: |
| 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 MqttSessionListener callbacks (onMessagePublished for success, onError for failure). | |
Class is used for managing MQTT session and publishing position data to MQTT broker.
Referenced from NavigineSdk.
Definition at line 19 of file NCMqttSession.h.
| - (void) addListener: | (nullable id< NCMqttSessionListener >) | listener |
Method is used to add MqttSessionListener class element which will notify about MQTT session connection state changes.
| listener | Сorresponding MqttSessionListener class. |
Swift code snippet:
Objective C code snippet:
| - (void) connect: | (nonnull NSString *) | server | |
| port: | (int32_t) | port | |
| username: | (nonnull NSString *) | username | |
| password: | (nonnull NSString *) | password |
Method is used to connect to MQTT broker and start publishing position data.
| server | MQTT broker server hostname or IP address. |
| port | MQTT broker server port. |
| username | MQTT broker username for authentication. |
| password | MQTT broker password for authentication. |
Swift code snippet:
Objective C code snippet:
| - (void) disconnect |
Method is used to disconnect from MQTT broker and stop publishing position data.
Swift code snippet:
Objective C code snippet:
| - (void) publish: | (nonnull NSString *) | topic | |
| message: | (nonnull NSString *) | message |
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 MqttSessionListener callbacks (onMessagePublished for success, onError for failure).
| topic | MQTT topic to publish the message to. Can be any valid MQTT topic string. |
| message | Message content to publish. Can be any string (JSON, plain text, etc.). |
Swift code snippet:
Objective C code snippet:
| - (void) removeListener: | (nullable id< NCMqttSessionListener >) | listener |
Method is used for removing previously added MqttSessionListener class element.
| listener | Сorresponding MqttSessionListener class to remove. |
Swift code snippet:
Objective C code snippet:
| - (void) setSubTopic: | (nonnull NSString *) | subTopic |
Method is used to set MQTT sub-topic for publishing position data. The final topic will be "navigine/mobile/positions/" + subTopic + "/" + deviceId.
| subTopic | MQTT sub-topic for publishing position data. Must match pattern [0-9a-zA-Z_-]+ and cannot be empty. |
Swift code snippet:
Objective C code snippet: