![]() |
PahoMqttCpp
MQTT C++ Client for POSIX and Windows
|
#include <token.h>
Public Types | |
| enum | Type { CONNECT , SUBSCRIBE , PUBLISH , UNSUBSCRIBE , DISCONNECT } |
| using | ptr_t = std::shared_ptr<token> |
| using | const_ptr_t = std::shared_ptr<const token> |
| using | weak_ptr_t = std::weak_ptr<token> |
Public Member Functions | |
| token (Type typ, iasync_client &cli) | |
| token (Type typ, iasync_client &cli, void *userContext, iaction_listener &cb) | |
| token (Type typ, iasync_client &cli, const string &topic) | |
| token (Type typ, iasync_client &cli, const string &topic, void *userContext, iaction_listener &cb) | |
| token (Type typ, iasync_client &cli, const_string_collection_ptr topics) | |
| token (Type typ, iasync_client &cli, const_string_collection_ptr topics, void *userContext, iaction_listener &cb) | |
| token (Type typ, iasync_client &cli, MQTTAsync_token tok) | |
| virtual | ~token () |
| Type | get_type () const |
| virtual iaction_listener * | get_action_callback () const |
| virtual iasync_client * | get_client () const |
| virtual int | get_message_id () const |
| virtual const_string_collection_ptr | get_topics () const |
| virtual void * | get_user_context () const |
| virtual bool | is_complete () const |
| operator bool () const | |
| virtual int | get_return_code () const |
| virtual void | set_action_callback (iaction_listener &listener) |
| virtual void | set_user_context (void *userContext) |
| void | set_num_expected (size_t n) |
| ReasonCode | get_reason_code () const |
| string | get_error_message () const |
| virtual void | wait () |
| virtual bool | try_wait () |
| virtual bool | wait_for (long timeout) |
| template<class Rep , class Period > | |
| bool | wait_for (const std::chrono::duration< Rep, Period > &relTime) |
| template<class Clock , class Duration > | |
| bool | wait_until (const std::chrono::time_point< Clock, Duration > &absTime) |
| connect_response | get_connect_response () const |
| subscribe_response | get_subscribe_response () const |
| unsubscribe_response | get_unsubscribe_response () const |
Static Public Member Functions | |
| static ptr_t | create (Type typ, iasync_client &cli) |
| static ptr_t | create (Type typ, iasync_client &cli, void *userContext, iaction_listener &cb) |
| static ptr_t | create (Type typ, iasync_client &cli, const string &topic) |
| static ptr_t | create (Type typ, iasync_client &cli, const string &topic, void *userContext, iaction_listener &cb) |
| static ptr_t | create (Type typ, iasync_client &cli, const_string_collection_ptr topics) |
| static ptr_t | create (Type typ, iasync_client &cli, const_string_collection_ptr topics, void *userContext, iaction_listener &cb) |
Friends | |
| class | async_client |
| class | mock_async_client |
| class | connect_options |
| class | response_options |
| class | delivery_response_options |
| class | disconnect_options |
Provides a mechanism for tracking the completion of an asynchronous action.
| using mqtt::token::ptr_t = std::shared_ptr<token> |
Smart/shared pointer to an object of this class
| using mqtt::token::const_ptr_t = std::shared_ptr<const token> |
Smart/shared pointer to an object of this class
| using mqtt::token::weak_ptr_t = std::weak_ptr<token> |
Weak pointer to an object of this class
| enum mqtt::token::Type |
|
inline |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
|
inline |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has completed |
|
inline |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topic | The topic associated with the token |
|
inline |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topic | The topic associated with the token |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has completed |
| mqtt::token::token | ( | Type | typ, |
| iasync_client & | cli, | ||
| const_string_collection_ptr | topics ) |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topics | The topics associated with the token |
| mqtt::token::token | ( | Type | typ, |
| iasync_client & | cli, | ||
| const_string_collection_ptr | topics, | ||
| void * | userContext, | ||
| iaction_listener & | cb ) |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topics | The topics associated with the token |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has completed |
| mqtt::token::token | ( | Type | typ, |
| iasync_client & | cli, | ||
| MQTTAsync_token | tok ) |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| tok | The message ID |
|
inlinevirtual |
Virtual destructor.
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has completed |
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topic | The topic associated with the token |
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topic | The topic associated with the token |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has completed |
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topics | The topics associated with the token |
|
inlinestatic |
Constructs a token object.
| typ | The type of request that the token is tracking. |
| cli | The client that created the token. |
| topics | The topics associated with the token |
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
| cb | callback listener that will be notified when subscribe has |
|
inline |
Gets the type of request the token is tracking, like CONNECT, PUBLISH, etc.
|
inlinevirtual |
Gets the action listener for this token.
|
inlinevirtual |
Returns the MQTT client that is responsible for processing the asynchronous action.
|
inlinevirtual |
Returns the ID of the message that is associated with the token.
|
inlinevirtual |
Gets the topic string(s) for the action being tracked by this token.
|
inlinevirtual |
Retrieve the context associated with an action.
|
inlinevirtual |
Returns whether or not the action has finished.
|
inlineexplicit |
Determines if the reference is valid. If the reference is invalid then it is not safe to call any member functions other than is_null() and empty()
|
inlinevirtual |
Gets the return code from the action. This is only valid after the action has completed (i.e. if is_complete() returns true).
|
virtual |
Register a listener to be notified when an action completes.
| listener | The callback to be notified when actions complete. |
|
inlinevirtual |
Store some context associated with an action.
| userContext | optional object used to pass context to the callback. Use nullptr if not required. |
|
inline |
Sets the number of results expected. This is only required for subscribe many() with < MQTTv5
| n | The number of results expected. |
|
inline |
Gets the reason code for the operation.
|
inline |
Get the error message from the C library
|
virtual |
Blocks the current thread until the action this token is associated with has completed.
|
inlinevirtual |
Non-blocking check to see if the action has completed.
|
inlinevirtual |
Blocks the current thread until the action this token is associated with has completed.
| timeout | The timeout (in milliseconds) |
|
inline |
Waits a relative amount of time for the action to complete.
| relTime | The amount of time to wait for the event. |
|
inline |
Waits until an absolute time for the action to complete.
| absTime | The absolute time to wait for the event. |
| connect_response mqtt::token::get_connect_response | ( | ) | const |
Gets the response from a connect operation. This returns the result of the completed operation. If the operation is not yet complete this will block until the result is available.
| subscribe_response mqtt::token::get_subscribe_response | ( | ) | const |
Gets the response from a connect operation. This returns the result of the completed operation. If the operation is not yet complete this will block until the result is available.
| unsubscribe_response mqtt::token::get_unsubscribe_response | ( | ) | const |
Gets the response from a connect operation. This returns the result of the completed operation. If the operation is not yet complete this will block until the result is available.
|
friend |
Client and token-related options have special access
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |