| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <title>mqttpp: mqtt/async_client.h Source File</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <link href="doxygen.css" rel="stylesheet" type="text/css"/> |
| </head> |
| <body> |
| <!-- Generated by Doxygen 1.6.1 --> |
| <div class="navigation" id="top"> |
| <div class="tabs"> |
| <ul> |
| <li><a href="main.html"><span>Main Page</span></a></li> |
| <li><a href="annotated.html"><span>Classes</span></a></li> |
| <li class="current"><a href="files.html"><span>Files</span></a></li> |
| </ul> |
| </div> |
| <div class="tabs"> |
| <ul> |
| <li><a href="files.html"><span>File List</span></a></li> |
| </ul> |
| </div> |
| <h1>mqtt/async_client.h</h1><a href="async__client_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
| <a name="l00002"></a>00002 |
| <a name="l00003"></a>00003 |
| <a name="l00004"></a>00004 |
| <a name="l00005"></a>00005 |
| <a name="l00006"></a>00006 |
| <a name="l00007"></a>00007 |
| <a name="l00008"></a>00008 <span class="comment">/*******************************************************************************</span> |
| <a name="l00009"></a>00009 <span class="comment"> * Copyright (c) 2013 Frank Pagliughi <fpagliughi@mindspring.com></span> |
| <a name="l00010"></a>00010 <span class="comment"> *</span> |
| <a name="l00011"></a>00011 <span class="comment"> * All rights reserved. This program and the accompanying materials</span> |
| <a name="l00012"></a>00012 <span class="comment"> * are made available under the terms of the Eclipse Public License v1.0</span> |
| <a name="l00013"></a>00013 <span class="comment"> * and Eclipse Distribution License v1.0 which accompany this distribution. </span> |
| <a name="l00014"></a>00014 <span class="comment"> *</span> |
| <a name="l00015"></a>00015 <span class="comment"> * The Eclipse Public License is available at </span> |
| <a name="l00016"></a>00016 <span class="comment"> * http://www.eclipse.org/legal/epl-v10.html</span> |
| <a name="l00017"></a>00017 <span class="comment"> * and the Eclipse Distribution License is available at </span> |
| <a name="l00018"></a>00018 <span class="comment"> * http://www.eclipse.org/org/documents/edl-v10.php.</span> |
| <a name="l00019"></a>00019 <span class="comment"> *</span> |
| <a name="l00020"></a>00020 <span class="comment"> * Contributors:</span> |
| <a name="l00021"></a>00021 <span class="comment"> * Frank Pagliughi - initial implementation and documentation</span> |
| <a name="l00022"></a>00022 <span class="comment"> *******************************************************************************/</span> |
| <a name="l00023"></a>00023 |
| <a name="l00024"></a>00024 <span class="preprocessor">#ifndef __mqtt_async_client_h</span> |
| <a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define __mqtt_async_client_h</span> |
| <a name="l00026"></a>00026 <span class="preprocessor"></span> |
| <a name="l00027"></a>00027 <span class="keyword">extern</span> <span class="stringliteral">"C"</span> { |
| <a name="l00028"></a>00028 <span class="preprocessor"> #include "MQTTAsync.h"</span> |
| <a name="l00029"></a>00029 } |
| <a name="l00030"></a>00030 |
| <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="token_8h.html" title="Declaration of MQTT token class.">mqtt/token.h</a>"</span> |
| <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="delivery__token_8h.html" title="Declaration of MQTT delivery_token class.">mqtt/delivery_token.h</a>"</span> |
| <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="iclient__persistence_8h.html" title="Declaration of MQTT iclient_persistence interface.">mqtt/iclient_persistence.h</a>"</span> |
| <a name="l00034"></a>00034 <span class="preprocessor">#include "<a class="code" href="iaction__listener_8h.html" title="Declaration of MQTT iaction_listener class.">mqtt/iaction_listener.h</a>"</span> |
| <a name="l00035"></a>00035 <span class="preprocessor">#include "<a class="code" href="connect__options_8h.html" title="Declaration of MQTT connect_options class.">mqtt/connect_options.h</a>"</span> |
| <a name="l00036"></a>00036 <span class="preprocessor">#include "<a class="code" href="exception_8h.html" title="Declaration of MQTT exception class.">mqtt/exception.h</a>"</span> |
| <a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="message_8h.html" title="Declaration of MQTT message class.">mqtt/message.h</a>"</span> |
| <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="callback_8h.html" title="Declaration of MQTT callback class.">mqtt/callback.h</a>"</span> |
| <a name="l00039"></a>00039 <span class="preprocessor">#include <string></span> |
| <a name="l00040"></a>00040 <span class="preprocessor">#include <vector></span> |
| <a name="l00041"></a>00041 <span class="preprocessor">#include <list></span> |
| <a name="l00042"></a>00042 <span class="preprocessor">#include <memory></span> |
| <a name="l00043"></a>00043 <span class="preprocessor">#include <stdexcept></span> |
| <a name="l00044"></a>00044 |
| <a name="l00045"></a>00045 <span class="keyword">namespace </span>mqtt { |
| <a name="l00046"></a>00046 |
| <a name="l00047"></a>00047 <span class="keyword">const</span> uint32_t VERSION = 0x00010000; |
| <a name="l00048"></a>00048 <span class="keyword">const</span> std::string VERSION_STR(<span class="stringliteral">"mqttpp v. 0.1"</span>), |
| <a name="l00049"></a>00049 COPYRIGHT(<span class="stringliteral">"Copyright (c) 2013 Frank Pagliughi"</span>); |
| <a name="l00050"></a>00050 |
| <a name="l00052"></a>00052 |
| <a name="l00066"></a><a class="code" href="classmqtt_1_1iasync__client.html">00066</a> <span class="keyword">class </span><a class="code" href="classmqtt_1_1iasync__client.html" title="Enables an application to communicate with an MQTT server using non-blocking methods...">iasync_client</a> |
| <a name="l00067"></a>00067 { |
| <a name="l00068"></a>00068 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classmqtt_1_1token.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">token</a>; |
| <a name="l00069"></a>00069 <span class="keyword">virtual</span> <span class="keywordtype">void</span> remove_token(<a class="code" href="classmqtt_1_1itoken.html" title="Provides a mechanism for tracking the completion of an asynchronous task.">itoken</a>* tok) =0; |
| <a name="l00070"></a>00070 |
| <a name="l00071"></a>00071 <span class="keyword">public</span>: |
| <a name="l00073"></a><a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad">00073</a> <span class="keyword">typedef</span> std::vector<std::string> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>; |
| <a name="l00075"></a><a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf">00075</a> <span class="keyword">typedef</span> std::vector<int> <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">qos_collection</a>; |
| <a name="l00076"></a>00076 |
| <a name="l00080"></a><a class="code" href="classmqtt_1_1iasync__client.html#a423bdce3b018de4597f773402f3eb360">00080</a> <span class="keyword">virtual</span> <a class="code" href="classmqtt_1_1iasync__client.html#a423bdce3b018de4597f773402f3eb360" title="Virtual destructor.">~iasync_client</a>() {} |
| <a name="l00087"></a>00087 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>() throw(<a class="code" href="classmqtt_1_1exception.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">exception</a>, <a class="code" href="classmqtt_1_1security__exception.html" title="Thrown when a client is not authorized to perform an operation, or if there is a...">security_exception</a>) =0; |
| <a name="l00095"></a>00095 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(<a class="code" href="classmqtt_1_1connect__options.html" title="Holds the set of options that control how the client connects to a server.">connect_options</a> options) |
| <a name="l00096"></a>00096 throw(exception, security_exception) =0; |
| <a name="l00106"></a>00106 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(<a class="code" href="classmqtt_1_1connect__options.html" title="Holds the set of options that control how the client connects to a server.">connect_options</a> options, <span class="keywordtype">void</span>* userContext, |
| <a name="l00107"></a>00107 <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) throw(exception, security_exception) =0; |
| <a name="l00117"></a>00117 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(<span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00118"></a>00118 throw(exception, security_exception) =0; |
| <a name="l00123"></a>00123 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>() throw(exception) =0; |
| <a name="l00130"></a>00130 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">long</span> quiesceTimeout) throw(exception) =0; |
| <a name="l00139"></a>00139 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">long</span> quiesceTimeout, <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00140"></a>00140 throw(exception) =0; |
| <a name="l00147"></a>00147 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00148"></a>00148 throw(exception) =0; |
| <a name="l00153"></a>00153 virtual idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af03b3ae480a762b2a655d5fe83f43096" title="Returns the delivery token for the specified message ID.">get_pending_delivery_token</a>(<span class="keywordtype">int</span> msgID) const =0; |
| <a name="l00158"></a>00158 virtual std::vector<idelivery_token_ptr> <a class="code" href="classmqtt_1_1iasync__client.html#a7c8ed0db731b51fe3b9634b92c5a77ef" title="Returns the delivery tokens for any outstanding publish operations.">get_pending_delivery_tokens</a>() const =0; |
| <a name="l00163"></a>00163 virtual std::<span class="keywordtype">string</span> <a class="code" href="classmqtt_1_1iasync__client.html#aef59cd111318d91a2455f1294a4b076b" title="Returns the client ID used by this client.">get_client_id</a>() const =0; |
| <a name="l00167"></a>00167 virtual std::<span class="keywordtype">string</span> <a class="code" href="classmqtt_1_1iasync__client.html#a86b6abefac7c06ece076645b41ec6862" title="Returns the address of the server used by this client.">get_server_uri</a>() const =0; |
| <a name="l00171"></a>00171 virtual <span class="keywordtype">bool</span> <a class="code" href="classmqtt_1_1iasync__client.html#a2c486e40ac2c91890d7ae40ef5223c92" title="Determines if this client is currently connected to the server.">is_connected</a>() const =0; |
| <a name="l00181"></a>00181 virtual idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(const std::<span class="keywordtype">string</span>& <a class="code" href="classmqtt_1_1topic.html" title="Represents a topic destination, used for publish/subscribe messaging.">topic</a>, const <span class="keywordtype">void</span>* payload, |
| <a name="l00182"></a>00182 <span class="keywordtype">size_t</span> n, <span class="keywordtype">int</span> qos, <span class="keywordtype">bool</span> retained) |
| <a name="l00183"></a>00183 throw(exception) =0; |
| <a name="l00195"></a>00195 virtual idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(const std::<span class="keywordtype">string</span>& topic, |
| <a name="l00196"></a>00196 const <span class="keywordtype">void</span>* payload, <span class="keywordtype">size_t</span> n, |
| <a name="l00197"></a>00197 <span class="keywordtype">int</span> qos, <span class="keywordtype">bool</span> retained, <span class="keywordtype">void</span>* userContext, |
| <a name="l00198"></a>00198 <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) throw(exception) =0; |
| <a name="l00209"></a>00209 virtual idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(const std::<span class="keywordtype">string</span>& topic, message_ptr msg) |
| <a name="l00210"></a>00210 throw(exception) =0; |
| <a name="l00220"></a>00220 virtual idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(const std::<span class="keywordtype">string</span>& topic, message_ptr msg, |
| <a name="l00221"></a>00221 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00222"></a>00222 throw(exception) =0; |
| <a name="l00228"></a>00228 virtual <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1iasync__client.html#ab02592cece3ea4f17164bf56ce7a16f2" title="Sets a callback listener to use for events that happen asynchronously.">set_callback</a>(<a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>& cb) throw(exception) =0; |
| <a name="l00236"></a>00236 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(const <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00237"></a>00237 const <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">qos_collection</a>& qos) |
| <a name="l00238"></a>00238 throw(std::invalid_argument,exception) =0; |
| <a name="l00248"></a>00248 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(const <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00249"></a>00249 const <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">qos_collection</a>& qos, |
| <a name="l00250"></a>00250 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00251"></a>00251 throw(std::invalid_argument,exception) =0; |
| <a name="l00259"></a>00259 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(const std::<span class="keywordtype">string</span>& topicFilter, <span class="keywordtype">int</span> qos) |
| <a name="l00260"></a>00260 throw(exception) =0; |
| <a name="l00270"></a>00270 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(const std::<span class="keywordtype">string</span>& topicFilter, <span class="keywordtype">int</span> qos, |
| <a name="l00271"></a>00271 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00272"></a>00272 throw(exception) =0; |
| <a name="l00279"></a>00279 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(const std::<span class="keywordtype">string</span>& topicFilter) throw(exception) =0; |
| <a name="l00285"></a>00285 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(const <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters) |
| <a name="l00286"></a>00286 throw(exception) =0; |
| <a name="l00295"></a>00295 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(const <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00296"></a>00296 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00297"></a>00297 throw(exception) =0; |
| <a name="l00306"></a>00306 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(const std::<span class="keywordtype">string</span>& topicFilter, |
| <a name="l00307"></a>00307 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00308"></a>00308 throw(exception) =0; |
| <a name="l00309"></a>00309 }; |
| <a name="l00310"></a>00310 |
| <a name="l00312"></a>00312 |
| <a name="l00317"></a><a class="code" href="classmqtt_1_1async__client.html">00317</a> class <a class="code" href="classmqtt_1_1async__client.html" title="Lightweight client for talking to an MQTT server using non-blocking methods that...">async_client</a> : public virtual <a class="code" href="classmqtt_1_1iasync__client.html" title="Enables an application to communicate with an MQTT server using non-blocking methods...">iasync_client</a> |
| <a name="l00318"></a>00318 { |
| <a name="l00319"></a>00319 <span class="keyword">public</span>: |
| <a name="l00321"></a><a class="code" href="classmqtt_1_1async__client.html#a42d365def574926bbf954e3804a15f90">00321</a> <span class="keyword">typedef</span> std::shared_ptr<async_client> ptr_t; |
| <a name="l00322"></a>00322 |
| <a name="l00323"></a>00323 <span class="keyword">private</span>: |
| <a name="l00325"></a>00325 <span class="keyword">typedef</span> std::unique_lock<std::mutex> guard; |
| <a name="l00326"></a>00326 |
| <a name="l00328"></a>00328 <span class="keyword">mutable</span> std::mutex lock_; |
| <a name="l00330"></a>00330 MQTTAsync cli_; |
| <a name="l00332"></a>00332 std::string serverURI_; |
| <a name="l00334"></a>00334 std::string clientId_; |
| <a name="l00336"></a>00336 MQTTClient_persistence* persist_; |
| <a name="l00338"></a>00338 <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>* userCallback_; |
| <a name="l00340"></a>00340 std::list<itoken_ptr> pendingTokens_; |
| <a name="l00342"></a>00342 std::list<idelivery_token_ptr> pendingDeliveryTokens_; |
| <a name="l00343"></a>00343 |
| <a name="l00344"></a>00344 <span class="keyword">static</span> <span class="keywordtype">void</span> on_connection_lost(<span class="keywordtype">void</span> *context, <span class="keywordtype">char</span> *cause); |
| <a name="l00345"></a>00345 <span class="keyword">static</span> <span class="keywordtype">int</span> on_message_arrived(<span class="keywordtype">void</span>* context, <span class="keywordtype">char</span>* topicName, <span class="keywordtype">int</span> topicLen, |
| <a name="l00346"></a>00346 MQTTAsync_message* msg); |
| <a name="l00347"></a>00347 <span class="keyword">static</span> <span class="keywordtype">void</span> on_delivery_complete(<span class="keywordtype">void</span>* context, MQTTAsync_token tok); |
| <a name="l00348"></a>00348 |
| <a name="l00350"></a><a class="code" href="classmqtt_1_1async__client.html#ad1520136c41afff5cd24bf19d9bf76e5">00350</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classmqtt_1_1token.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">token</a>; |
| <a name="l00351"></a>00351 <span class="keyword">virtual</span> <span class="keywordtype">void</span> add_token(itoken_ptr tok); |
| <a name="l00352"></a>00352 <span class="keyword">virtual</span> <span class="keywordtype">void</span> add_token(idelivery_token_ptr tok); |
| <a name="l00353"></a>00353 <span class="keyword">virtual</span> <span class="keywordtype">void</span> remove_token(<a class="code" href="classmqtt_1_1itoken.html" title="Provides a mechanism for tracking the completion of an asynchronous task.">itoken</a>* tok); |
| <a name="l00354"></a>00354 <span class="keyword">virtual</span> <span class="keywordtype">void</span> remove_token(itoken_ptr tok) { remove_token(tok.get()); } |
| <a name="l00355"></a>00355 <span class="keywordtype">void</span> remove_token(idelivery_token_ptr tok) { remove_token(tok.get()); } |
| <a name="l00356"></a>00356 |
| <a name="l00358"></a>00358 std::vector<char*> alloc_topic_filters( |
| <a name="l00359"></a>00359 <span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters); |
| <a name="l00360"></a>00360 <span class="keywordtype">void</span> free_topic_filters(std::vector<char*>& filts); |
| <a name="l00361"></a>00361 |
| <a name="l00366"></a>00366 callback* get_callback()<span class="keyword"> const </span>{ |
| <a name="l00367"></a>00367 guard g(lock_); |
| <a name="l00368"></a>00368 <span class="keywordflow">return</span> userCallback_; |
| <a name="l00369"></a>00369 } |
| <a name="l00370"></a>00370 |
| <a name="l00372"></a>00372 async_client() =<span class="keyword">delete</span>; |
| <a name="l00373"></a>00373 async_client(<span class="keyword">const</span> async_client&) =<span class="keyword">delete</span>; |
| <a name="l00374"></a>00374 async_client& operator=(<span class="keyword">const</span> async_client&) =<span class="keyword">delete</span>; |
| <a name="l00375"></a>00375 |
| <a name="l00376"></a>00376 <span class="keyword">public</span>: |
| <a name="l00384"></a>00384 async_client(<span class="keyword">const</span> std::string& serverURI, <span class="keyword">const</span> std::string& clientId); |
| <a name="l00393"></a>00393 async_client(<span class="keyword">const</span> std::string& serverURI, <span class="keyword">const</span> std::string& clientId, |
| <a name="l00394"></a>00394 <span class="keyword">const</span> std::string& persistDir); |
| <a name="l00405"></a>00405 async_client(<span class="keyword">const</span> std::string& serverURI, <span class="keyword">const</span> std::string& clientId, |
| <a name="l00406"></a>00406 iclient_persistence* persistence); |
| <a name="l00410"></a>00410 ~async_client(); |
| <a name="l00417"></a>00417 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>() throw(exception, security_exception); |
| <a name="l00425"></a>00425 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(connect_options options) throw(exception, security_exception); |
| <a name="l00435"></a>00435 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(connect_options options, <span class="keywordtype">void</span>* userContext, |
| <a name="l00436"></a>00436 iaction_listener& cb) throw(exception, security_exception); |
| <a name="l00446"></a>00446 virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aa617f0e2b4ed0fe4648bbefdc6433d27" title="Connects to an MQTT server using the default options.">connect</a>(<span class="keywordtype">void</span>* userContext, iaction_listener& cb) |
| <a name="l00447"></a>00447 throw(exception, security_exception); |
| <a name="l00452"></a><a class="code" href="classmqtt_1_1async__client.html#a96d349ba04e4866ec9627999f9d10ab9">00452</a> virtual itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>() throw(exception) { <span class="keywordflow">return</span> <a class="code" href="classmqtt_1_1async__client.html#a96d349ba04e4866ec9627999f9d10ab9" title="Disconnects from the server.">disconnect</a>(0L); } |
| <a name="l00459"></a>00459 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">long</span> quiesceTimeout) <span class="keywordflow">throw</span>(exception); |
| <a name="l00468"></a>00468 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">long</span> quiesceTimeout, <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00469"></a>00469 <span class="keywordflow">throw</span>(exception); |
| <a name="l00476"></a><a class="code" href="classmqtt_1_1async__client.html#ac15435d6cab4825b31935c9429d533db">00476</a> <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1async__client.html#ac15435d6cab4825b31935c9429d533db" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) <span class="keywordflow">throw</span>(exception) { |
| <a name="l00477"></a>00477 <span class="keywordflow">return</span> <a class="code" href="classmqtt_1_1iasync__client.html#aff2ecf209f7ab77d08b38510880f32ca" title="Disconnects from the server.">disconnect</a>(0L, userContext, cb); |
| <a name="l00478"></a>00478 } |
| <a name="l00483"></a>00483 <span class="keyword">virtual</span> idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af03b3ae480a762b2a655d5fe83f43096" title="Returns the delivery token for the specified message ID.">get_pending_delivery_token</a>(<span class="keywordtype">int</span> msgID) <span class="keyword">const</span>; |
| <a name="l00488"></a>00488 <span class="keyword">virtual</span> std::vector<idelivery_token_ptr> <a class="code" href="classmqtt_1_1iasync__client.html#a7c8ed0db731b51fe3b9634b92c5a77ef" title="Returns the delivery tokens for any outstanding publish operations.">get_pending_delivery_tokens</a>() <span class="keyword">const</span>; |
| <a name="l00493"></a><a class="code" href="classmqtt_1_1async__client.html#a1baa62fe711634bd6801d7593e4c58a8">00493</a> <span class="keyword">virtual</span> std::string <a class="code" href="classmqtt_1_1async__client.html#a1baa62fe711634bd6801d7593e4c58a8" title="Returns the client ID used by this client.">get_client_id</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> clientId_; } |
| <a name="l00497"></a><a class="code" href="classmqtt_1_1async__client.html#a05df75535441351d4aa2e8aa2068c825">00497</a> <span class="keyword">virtual</span> std::string <a class="code" href="classmqtt_1_1async__client.html#a05df75535441351d4aa2e8aa2068c825" title="Returns the address of the server used by this client.">get_server_uri</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> serverURI_; } |
| <a name="l00501"></a><a class="code" href="classmqtt_1_1async__client.html#a2342093dc3dc89ffcc42ec38b574cf71">00501</a> <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classmqtt_1_1async__client.html#a2342093dc3dc89ffcc42ec38b574cf71" title="Determines if this client is currently connected to the server.">is_connected</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> MQTTAsync_isConnected(cli_) != 0; } |
| <a name="l00511"></a>00511 <span class="keyword">virtual</span> idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(<span class="keyword">const</span> std::string& topic, <span class="keyword">const</span> <span class="keywordtype">void</span>* payload, |
| <a name="l00512"></a>00512 <span class="keywordtype">size_t</span> n, <span class="keywordtype">int</span> qos, <span class="keywordtype">bool</span> retained) <span class="keywordflow">throw</span>(exception); |
| <a name="l00524"></a>00524 <span class="keyword">virtual</span> idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(<span class="keyword">const</span> std::string& topic, |
| <a name="l00525"></a>00525 <span class="keyword">const</span> <span class="keywordtype">void</span>* payload, <span class="keywordtype">size_t</span> n, |
| <a name="l00526"></a>00526 <span class="keywordtype">int</span> qos, <span class="keywordtype">bool</span> retained, <span class="keywordtype">void</span>* userContext, |
| <a name="l00527"></a>00527 <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) <span class="keywordflow">throw</span>(exception); |
| <a name="l00538"></a>00538 <span class="keyword">virtual</span> idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(<span class="keyword">const</span> std::string& topic, message_ptr msg) |
| <a name="l00539"></a>00539 <span class="keywordflow">throw</span>(exception); |
| <a name="l00549"></a>00549 <span class="keyword">virtual</span> idelivery_token_ptr <a class="code" href="classmqtt_1_1iasync__client.html#af70d2c1bff1f5ca2e26996870c3cbba7" title="Publishes a message to a topic on the server.">publish</a>(<span class="keyword">const</span> std::string& topic, message_ptr msg, |
| <a name="l00550"></a>00550 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& cb) |
| <a name="l00551"></a>00551 <span class="keywordflow">throw</span>(exception); |
| <a name="l00557"></a>00557 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1iasync__client.html#ab02592cece3ea4f17164bf56ce7a16f2" title="Sets a callback listener to use for events that happen asynchronously.">set_callback</a>(<a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>& cb) <span class="keywordflow">throw</span>(exception); |
| <a name="l00565"></a>00565 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00566"></a>00566 <span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">qos_collection</a>& qos) |
| <a name="l00567"></a>00567 <span class="keywordflow">throw</span>(std::invalid_argument,exception); |
| <a name="l00577"></a>00577 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00578"></a>00578 <span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">qos_collection</a>& qos, |
| <a name="l00579"></a>00579 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00580"></a>00580 <span class="keywordflow">throw</span>(std::invalid_argument,exception); |
| <a name="l00588"></a>00588 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(<span class="keyword">const</span> std::string& topicFilter, <span class="keywordtype">int</span> qos) |
| <a name="l00589"></a>00589 <span class="keywordflow">throw</span>(exception); |
| <a name="l00599"></a>00599 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#ab024f5d92d340ce3355229fbe6ceaf20" title="Subscribe to multiple topics, each of which may include wildcards.">subscribe</a>(<span class="keyword">const</span> std::string& topicFilter, <span class="keywordtype">int</span> qos, |
| <a name="l00600"></a>00600 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00601"></a>00601 <span class="keywordflow">throw</span>(exception); |
| <a name="l00608"></a>00608 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> std::string& topicFilter) <span class="keywordflow">throw</span>(exception); |
| <a name="l00614"></a>00614 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters) |
| <a name="l00615"></a>00615 <span class="keywordflow">throw</span>(exception); |
| <a name="l00624"></a>00624 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">topic_filter_collection</a>& topicFilters, |
| <a name="l00625"></a>00625 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00626"></a>00626 <span class="keywordflow">throw</span>(exception); |
| <a name="l00635"></a>00635 <span class="keyword">virtual</span> itoken_ptr <a class="code" href="classmqtt_1_1iasync__client.html#a2b103506bf4d5d3d1702262588214acc" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> std::string& topicFilter, |
| <a name="l00636"></a>00636 <span class="keywordtype">void</span>* userContext, <a class="code" href="classmqtt_1_1iaction__listener.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">iaction_listener</a>& <a class="code" href="classmqtt_1_1callback.html" title="Provides a mechanism for tracking the completion of an asynchronous action.">callback</a>) |
| <a name="l00637"></a>00637 <span class="keywordflow">throw</span>(exception); |
| <a name="l00638"></a>00638 }; |
| <a name="l00639"></a>00639 |
| <a name="l00643"></a>00643 <span class="keyword">typedef</span> <a class="code" href="classmqtt_1_1async__client.html#a42d365def574926bbf954e3804a15f90" title="Pointer type for this object.">async_client::ptr_t</a> async_client_ptr; |
| <a name="l00644"></a>00644 |
| <a name="l00646"></a>00646 <span class="comment">// end namespace mqtt</span> |
| <a name="l00647"></a>00647 } |
| <a name="l00648"></a>00648 |
| <a name="l00649"></a>00649 <span class="preprocessor">#endif // __mqtt_async_client_h</span> |
| <a name="l00650"></a>00650 <span class="preprocessor"></span> |
| </pre></div></div> |
| <hr size="1"/><address style="text-align: right;"><small>Generated on 30 Apr 2014 for mqttpp by |
| <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> |
| </body> |
| </html> |