objc

Instance Methods | Class Methods
MQTT Class Reference

An MQTT client. More...

#import <Network/Network.h>

Inheritance diagram for MQTT:
Inheritance graph
[legend]
Collaboration diagram for MQTT:
Collaboration graph
[legend]

Instance Methods

(id< MQTTDelegate >) - delegate
 Gets the current MQTT delegate. More...
 
(void) - setDelegate:
 Sets the MQTT delegate. More...
 
(BOOL- connect
 Begin an asynchronous connection to the configured MQTT broker. More...
 
(BOOL- connectWithUser:password:
 Begin an asynchronous connection with credentials. More...
 
(BOOL- disconnect
 Begin an asynchronous disconnect from the broker. More...
 
(BOOL- publishString:toTopic:qos:retain:
 Publish a string payload to a topic. More...
 
(BOOL- publishData:toTopic:qos:retain:
 Publish binary data to a topic. More...
 
(BOOL- publishJSON:toTopic:qos:retain:
 Publish a JSON-encoded object to a topic. More...
 
- Instance Methods inherited from NXObject
(id- retain
 Increases the retain count of the receiver. More...
 
(void) - release
 Decreases the retain count of the receiver. More...
 
(id- autorelease
 Adds the receiver to the autorelease pool.
 
- Instance Methods inherited from Object
(void) - dealloc
 Free resources for an existing instance.
 
(id- init
 Initialize the instance, after allocation. More...
 
(Class- class
 Returns the class of the instance. More...
 
(Class- superclass
 Returns the superclass of the instance. More...
 
(BOOL- isEqual:
 Compares the receiver to another object for equality. More...
 
(BOOL- isKindOfClass:
 Returns a Boolean value that indicates whether the receiver is an instance of a given class. More...
 
(BOOL- conformsTo:
 Checks if the receiver's class conforms to a protocol. More...
 
(NXString *) - description
 Returns a string that represents the instance. More...
 
- Instance Methods inherited from <ObjectProtocol>
(BOOL- respondsToSelector:
 Checks if the receiver responds to a selector. More...
 

Class Methods

(MQTT *) + clientWithHost:
 Creates a new MQTT client. More...
 
(MQTT *) + clientWithHost:port:clientIdentifier:timeout:
 Creates a new MQTT client. More...
 
- Class Methods inherited from NXObject
(id+ allocWithZone:
 Allocates a new instance of an object in a specific memory zone. More...
 
- Class Methods inherited from Object
(void) + initialize
 Performs one-time initialization for the class. More...
 
(id+ alloc
 Allocate a new class instance. More...
 
(Class+ class
 Returns the class object. More...
 
(Class+ superclass
 Returns the superclass of the class. More...
 
(const char *) + name
 Returns the name of the class. More...
 
(BOOL+ conformsTo:
 Checks if the class conforms to a protocol. More...
 
(NXString *) + description
 Returns a string that represents the class. More...
 

Additional Inherited Members

- Protected Attributes inherited from NXObject
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.
 
- Protected Attributes inherited from Object
Class isa
 A pointer to the object's class structure. More...
 

Detailed Description

An MQTT client.

Definition at line 14 of file MQTT.h.

Method Documentation

◆ clientWithHost:()

+ (MQTT *) clientWithHost: (id< NXConstantStringProtocol >)  host

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:()

+ (MQTT *) clientWithHost: (id< NXConstantStringProtocol >)  host
port: (uint16_t)  port
clientIdentifier: (id< NXConstantStringProtocol >)  clientIdentifier
timeout: (NXTimeInterval 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()

- (BOOL) 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:()

- (BOOL) connectWithUser: (id< NXConstantStringProtocol >)  user
password: (id< NXConstantStringProtocol >)  password 

Begin an asynchronous connection with credentials.

Parameters
userUsername for authentication.
passwordPassword 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()

- (id<MQTTDelegate>) 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()

- (BOOL) 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:()

- (BOOL) publishData: (NSData *)  data
toTopic: (id< NXConstantStringProtocol >)  topic
qos: (uint8_t)  qos
retain: (BOOL retain 

Publish binary data to a topic.

Parameters
dataData payload to publish. May be empty.
topicTopic name to publish to; must be non-empty.
qosQuality of Service level: 0, 1, or 2.
retainWhen 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:()

- (BOOL) publishJSON: (id< JSONProtocol >)  json
toTopic: (id< NXConstantStringProtocol >)  topic
qos: (uint8_t)  qos
retain: (BOOL retain 

Publish a JSON-encoded object to a topic.

Parameters
jsonObject conforming to JSONProtocol; serialized to JSON.
topicTopic name to publish to; must be non-empty.
qosQuality of Service level: 0, 1, or 2.
retainWhen 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:()

- (BOOL) publishString: (id< NXConstantStringProtocol >)  message
toTopic: (id< NXConstantStringProtocol >)  topic
qos: (uint8_t)  qos
retain: (BOOL retain 

Publish a string payload to a topic.

Parameters
messageString to publish
topicTopic name to publish to; must be non-empty.
qosQuality of Service level: 0, 1, or 2.
retainWhen 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:()

- (void) setDelegate: (id< MQTTDelegate >)  delegate

Sets the MQTT delegate.

Parameters
delegateThe 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: