Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
mqtt::iasync_client Class Referenceabstract

Enables an application to communicate with an MQTT server using non-blocking methods. More...

#include <iasync_client.h>

Inheritance diagram for mqtt::iasync_client:
mqtt::async_client

Public Types

using qos_collection = std::vector< int >
 Type for a collection of QOS values.
 

Public Member Functions

virtual ~iasync_client ()
 Virtual destructor.
 
virtual token_ptr connect ()=0
 Connects to an MQTT server using the default options. More...
 
virtual token_ptr connect (connect_options options)=0
 Connects to an MQTT server using the provided connect options. More...
 
virtual token_ptr connect (connect_options options, void *userContext, iaction_listener &cb)=0
 Connects to an MQTT server using the specified options. More...
 
virtual token_ptr connect (void *userContext, iaction_listener &cb)=0
 
virtual token_ptr reconnect ()=0
 Reconnects the client using options from the previous connect. More...
 
virtual token_ptr disconnect ()=0
 Disconnects from the server. More...
 
virtual token_ptr disconnect (disconnect_options opts)=0
 Disconnects from the server. More...
 
virtual token_ptr disconnect (int timeout)=0
 Disconnects from the server. More...
 
virtual token_ptr disconnect (int timeout, void *userContext, iaction_listener &cb)=0
 Disconnects from the server. More...
 
virtual token_ptr disconnect (void *userContext, iaction_listener &cb)=0
 Disconnects from the server. More...
 
virtual delivery_token_ptr get_pending_delivery_token (int msgID) const =0
 Returns the delivery token for the specified message ID. More...
 
virtual std::vector
< delivery_token_ptr > 
get_pending_delivery_tokens () const =0
 Returns the delivery tokens for any outstanding publish operations. More...
 
virtual string get_client_id () const =0
 Returns the client ID used by this client. More...
 
virtual string get_server_uri () const =0
 Returns the address of the server used by this client.
 
virtual bool is_connected () const =0
 Determines if this client is currently connected to the server.
 
virtual delivery_token_ptr publish (string_ref topic, const void *payload, size_t n, int qos, bool retained)=0
 Publishes a message to a topic on the server. More...
 
virtual delivery_token_ptr publish (string_ref topic, const void *payload, size_t n)=0
 Publishes a message to a topic on the server. More...
 
virtual delivery_token_ptr publish (string_ref topic, const void *payload, size_t n, int qos, bool retained, void *userContext, iaction_listener &cb)=0
 Publishes a message to a topic on the server. More...
 
virtual delivery_token_ptr publish (string_ref topic, binary_ref payload, int qos, bool retained)=0
 Publishes a message to a topic on the server. More...
 
virtual delivery_token_ptr publish (string_ref topic, binary_ref payload)=0
 Publishes a message to a topic on the server. More...
 
virtual delivery_token_ptr publish (const_message_ptr msg)=0
 Publishes a message to a topic on the server Takes an Message message and delivers it to the server at the requested quality of service. More...
 
virtual delivery_token_ptr publish (const_message_ptr msg, void *userContext, iaction_listener &cb)=0
 Publishes a message to a topic on the server. More...
 
virtual void set_callback (callback &cb)=0
 Sets a callback listener to use for events that happen asynchronously. More...
 
virtual void disable_callbacks ()=0
 Stops the callbacks.
 
virtual token_ptr subscribe (const_string_collection_ptr topicFilters, const qos_collection &qos)=0
 Subscribe to multiple topics, each of which may include wildcards. More...
 
virtual token_ptr subscribe (const_string_collection_ptr topicFilters, const qos_collection &qos, void *userContext, iaction_listener &callback)=0
 Subscribes to multiple topics, each of which may include wildcards. More...
 
virtual token_ptr subscribe (const string &topicFilter, int qos)=0
 Subscribe to a topic, which may include wildcards. More...
 
virtual token_ptr subscribe (const string &topicFilter, int qos, void *userContext, iaction_listener &callback)=0
 Subscribe to a topic, which may include wildcards. More...
 
virtual token_ptr unsubscribe (const string &topicFilter)=0
 Requests the server unsubscribe the client from a topic. More...
 
virtual token_ptr unsubscribe (const_string_collection_ptr topicFilters)=0
 Requests the server unsubscribe the client from one or more topics. More...
 
virtual token_ptr unsubscribe (const_string_collection_ptr topicFilters, void *userContext, iaction_listener &cb)=0
 Requests the server unsubscribe the client from one or more topics. More...
 
virtual token_ptr unsubscribe (const string &topicFilter, void *userContext, iaction_listener &cb)=0
 Requests the server unsubscribe the client from a topics. More...
 

Friends

class token
 

Detailed Description

Enables an application to communicate with an MQTT server using non-blocking methods.

It provides applications a simple programming interface to all features of the MQTT version 3.1 specification including:

  • connect
  • publish
  • subscribe
  • unsubscribe
  • disconnect

Member Function Documentation

virtual token_ptr mqtt::iasync_client::connect ( )
pure virtual

Connects to an MQTT server using the default options.

Returns
token used to track and wait for the connect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor non security related problems
security_exceptionfor security related problems

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::connect ( connect_options  options)
pure virtual

Connects to an MQTT server using the provided connect options.

Parameters
optionsa set of connection parameters that override the defaults.
Returns
token used to track and wait for the connect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor non security related problems
security_exceptionfor security related problems

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::connect ( connect_options  options,
void *  userContext,
iaction_listener cb 
)
pure virtual

Connects to an MQTT server using the specified options.

Parameters
optionsa set of connection parameters that override the defaults.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cbcallback listener that will be notified when the connect completes.
Returns
token used to track and wait for the connect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor non security related problems
security_exceptionfor security related problems

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::connect ( void *  userContext,
iaction_listener cb 
)
pure virtual
Parameters
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cblistener that will be notified when the connect completes.
Returns
token used to track and wait for the connect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor non security related problems
security_exceptionfor security related problems

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::disconnect ( )
pure virtual

Disconnects from the server.

Returns
token used to track and wait for the disconnect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor problems encountered while disconnecting

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::disconnect ( disconnect_options  opts)
pure virtual

Disconnects from the server.

Parameters
optsOptions for disconnecting.
Returns
token used to track and wait for the disconnect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor problems encountered while disconnecting

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::disconnect ( int  timeout)
pure virtual

Disconnects from the server.

Parameters
timeoutthe amount of time in milliseconds to allow for existing work to finish before disconnecting. A value of zero or less means the client will not quiesce.
Returns
token used to track and wait for the disconnect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor problems encountered while disconnecting

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::disconnect ( int  timeout,
void *  userContext,
iaction_listener cb 
)
pure virtual

Disconnects from the server.

Parameters
timeoutthe amount of time in milliseconds to allow for existing work to finish before disconnecting. A value of zero or less means the client will not quiesce.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cblistener that will be notified when the disconnect completes.
Returns
token used to track and wait for the disconnect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor problems encountered while disconnecting

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::disconnect ( void *  userContext,
iaction_listener cb 
)
pure virtual

Disconnects from the server.

Parameters
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cblistener that will be notified when the disconnect completes.
Returns
token used to track and wait for the disconnect to complete. The token will be passed to any callback that has been set.
Exceptions
exceptionfor problems encountered while disconnecting

Implemented in mqtt::async_client.

virtual string mqtt::iasync_client::get_client_id ( ) const
pure virtual

Returns the client ID used by this client.

Returns
string

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::get_pending_delivery_token ( int  msgID) const
pure virtual

Returns the delivery token for the specified message ID.

Returns
delivery_token

Implemented in mqtt::async_client.

virtual std::vector<delivery_token_ptr> mqtt::iasync_client::get_pending_delivery_tokens ( ) const
pure virtual

Returns the delivery tokens for any outstanding publish operations.

Returns
delivery_token[]

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( string_ref  topic,
const void *  payload,
size_t  n,
int  qos,
bool  retained 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
topicThe topic to deliver the message to
payloadthe bytes to use as the message payload
nthe number of bytes in the payload
qosthe Quality of Service to deliver the message at. Valid values are 0, 1 or 2.
retainedwhether or not this message should be retained by the server.
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( string_ref  topic,
const void *  payload,
size_t  n 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
topicThe topic to deliver the message to
payloadthe bytes to use as the message payload
nthe number of bytes in the payload
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( string_ref  topic,
const void *  payload,
size_t  n,
int  qos,
bool  retained,
void *  userContext,
iaction_listener cb 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
topicThe topic to deliver the message to
payloadthe bytes to use as the message payload
nthe number of bytes in the payload
qosthe Quality of Service to deliver the message at. Valid values are 0, 1 or 2.
retainedwhether or not this message should be retained by the server.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cb
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( string_ref  topic,
binary_ref  payload,
int  qos,
bool  retained 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
topicThe topic to deliver the message to
payloadthe bytes to use as the message payload
qosthe Quality of Service to deliver the message at. Valid values are 0, 1 or 2.
retainedwhether or not this message should be retained by the server.
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( string_ref  topic,
binary_ref  payload 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
topicThe topic to deliver the message to
payloadthe bytes to use as the message payload
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( const_message_ptr  msg)
pure virtual

Publishes a message to a topic on the server Takes an Message message and delivers it to the server at the requested quality of service.

Parameters
msgthe message to deliver to the server
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual delivery_token_ptr mqtt::iasync_client::publish ( const_message_ptr  msg,
void *  userContext,
iaction_listener cb 
)
pure virtual

Publishes a message to a topic on the server.

Parameters
msgthe message to deliver to the server
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cboptional listener that will be notified when message delivery has completed to the requested quality of service
Returns
token used to track and wait for the publish to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::reconnect ( )
pure virtual

Reconnects the client using options from the previous connect.

The client must have previously called connect() for this to work.

Returns
token used to track the progress of the reconnect.

Implemented in mqtt::async_client.

virtual void mqtt::iasync_client::set_callback ( callback cb)
pure virtual

Sets a callback listener to use for events that happen asynchronously.

Parameters
cbcallback which will be invoked for certain asynchronous events

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::subscribe ( const_string_collection_ptr  topicFilters,
const qos_collection qos 
)
pure virtual

Subscribe to multiple topics, each of which may include wildcards.

Provides an optimized way to subscribe to multiple topics compared to subscribing to each one individually.

Parameters
topicFiltersone or more topics to subscribe to, which can include wildcards
qosthe maximum quality of service at which to subscribe. Messages published at a lower quality of service will be received at the published QoS. Messages published at a higher quality of service will be received using the QoS specified on the subscribe.
Returns
token used to track and wait for the subscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::subscribe ( const_string_collection_ptr  topicFilters,
const qos_collection qos,
void *  userContext,
iaction_listener callback 
)
pure virtual

Subscribes to multiple topics, each of which may include wildcards.

Parameters
topicFiltersone or more topics to subscribe to, which can include wildcards
qosthe maximum quality of service at which to subscribe. Messages published at a lower quality of service will be received at the published QoS. Messages published at a higher quality of service will be received using the QoS specified on the subscribe.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
callbacklistener that will be notified when subscribe has completed
Returns
token used to track and wait for the subscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::subscribe ( const string &  topicFilter,
int  qos 
)
pure virtual

Subscribe to a topic, which may include wildcards.

Parameters
topicFilterthe topic to subscribe to, which can include wildcards.
qosthe maximum quality of service at which to subscribe. Messages published at a lower quality of service will be received at the published QoS. Messages published at a higher quality of service will be received using the QoS specified on the subscribe.
Returns
token used to track and wait for the subscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::subscribe ( const string &  topicFilter,
int  qos,
void *  userContext,
iaction_listener callback 
)
pure virtual

Subscribe to a topic, which may include wildcards.

Parameters
topicFilterthe topic to subscribe to, which can include wildcards.
qosthe maximum quality of service at which to subscribe. Messages published at a lower quality of service will be received at the published QoS. Messages published at a higher quality of service will be received using the QoS specified on the subscribe.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
callbacklistener that will be notified when subscribe has completed
Returns
token used to track and wait for the subscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::unsubscribe ( const string &  topicFilter)
pure virtual

Requests the server unsubscribe the client from a topic.

Parameters
topicFilterthe topic to unsubscribe from. It must match a topicFilter specified on an earlier subscribe.
Returns
token used to track and wait for the unsubscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::unsubscribe ( const_string_collection_ptr  topicFilters)
pure virtual

Requests the server unsubscribe the client from one or more topics.

Parameters
topicFiltersone or more topics to unsubscribe from. Each topicFilter must match one specified on an earlier subscribe.
Returns
token used to track and wait for the unsubscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::unsubscribe ( const_string_collection_ptr  topicFilters,
void *  userContext,
iaction_listener cb 
)
pure virtual

Requests the server unsubscribe the client from one or more topics.

Parameters
topicFiltersone or more topics to unsubscribe from. Each topicFilter must match one specified on an earlier subscribe.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cblistener that will be notified when unsubscribe has completed
Returns
token used to track and wait for the unsubscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.

virtual token_ptr mqtt::iasync_client::unsubscribe ( const string &  topicFilter,
void *  userContext,
iaction_listener cb 
)
pure virtual

Requests the server unsubscribe the client from a topics.

Parameters
topicFilterthe topic to unsubscribe from. It must match a topicFilter specified on an earlier subscribe.
userContextoptional object used to pass context to the callback. Use nullptr if not required.
cblistener that will be notified when unsubscribe has completed
Returns
token used to track and wait for the unsubscribe to complete. The token will be passed to callback methods if set.

Implemented in mqtt::async_client.


The documentation for this class was generated from the following file: