An MQTT client.
More...
#import <Network/Network.h>
|
|
id | _zone |
| | The memory zone where the object is allocated.
|
| |
|
unsigned short | _retain |
| | The retain count of the object.
|
| |
|
id | _next |
| | The next object in an autorelease pool.
|
| |
| Class | isa |
| | A pointer to the object's class structure. More...
|
| |
An MQTT client.
Definition at line 14 of file MQTT.h.
◆ clientWithHost:()
Creates a new MQTT client.
- Returns
- A pointer to the newly created MQTT client, or NULL on failure.
This method creates a new MQTT client instance, without connecting to the host.
◆ clientWithHost:port:clientIdentifier:timeout:()
Creates a new MQTT client.
- Returns
- A pointer to the newly created MQTT client, or NULL on failure.
This method creates a new MQTT client instance, without connecting to the host, but also allows port, client identifier and timeout to be specified.
◆ connect()
Begin an asynchronous connection to the configured MQTT broker.
- Returns
- YES if the connection request was initiated; NO on immediate failure.
Uses the host, port, and client identifier configured for this instance. Connection progress and errors are delivered via the delegate callbacks. This method does not block.
◆ connectWithUser:password:()
Begin an asynchronous connection with credentials.
- Parameters
-
| user | Username for authentication. |
| password | Password for authentication. |
- Returns
- YES if the connection request was initiated; NO on immediate failure.
This method behaves like -connect but supplies credentials to the broker. Progress and errors are reported via the delegate. This method does not block.
◆ delegate()
Gets the current MQTT delegate.
- Returns
- The current MQTT delegate, or nil if no delegate is set.
This method returns the object that serves as the MQTT delegate.
◆ disconnect()
Begin an asynchronous disconnect from the broker.
- Returns
- YES if the disconnect was requested; NO if not connected or request could not be queued.
Completion is reported via the delegate. This method does not block.
◆ publishData:toTopic:qos:retain:()
Publish binary data to a topic.
- Parameters
-
| data | Data payload to publish. May be empty. |
| topic | Topic name to publish to; must be non-empty. |
| qos | Quality of Service level: 0, 1, or 2. |
| retain | When YES, sets the retain flag on the message. |
- Returns
- YES if the message was queued; NO on immediate failure.
Payload size may be limited by the underlying stack (typically ≤ 65535 bytes).
◆ publishJSON:toTopic:qos:retain:()
Publish a JSON-encoded object to a topic.
- Parameters
-
| json | Object conforming to JSONProtocol; serialized to JSON. |
| topic | Topic name to publish to; must be non-empty. |
| qos | Quality of Service level: 0, 1, or 2. |
| retain | When YES, sets the retain flag on the message. |
- Returns
- YES if the message was queued; NO on immediate failure or if JSON serialization fails.
◆ publishString:toTopic:qos:retain:()
Publish a string payload to a topic.
- Parameters
-
| message | String to publish |
| topic | Topic name to publish to; must be non-empty. |
| qos | Quality of Service level: 0, 1, or 2. |
| retain | When YES, sets the retain flag on the message. |
- Returns
- YES if the message was queued; NO on immediate failure (not connected, invalid parameters, or resource exhaustion).
The call is asynchronous and does not wait for broker acknowledgements.
◆ setDelegate:()
Sets the MQTT delegate.
- Parameters
-
| delegate | The object to set as the MQTT delegate, or nil to remove the current delegate. |
The delegate object will receive MQTT-related callbacks when the MQTT state changes. The delegate should conform to the MQTTDelegate protocol.
The documentation for this class was generated from the following file: