blob: 74bd0959a21e1e82da0592283b904ae952ca2c23 [file] [log] [blame]
<!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/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&nbsp;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&nbsp;List</span></a></li>
</ul>
</div>
<h1>mqtt/client.h</h1><a href="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 &lt;fpagliughi@mindspring.com&gt;</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_client_h</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#define __mqtt_client_h</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span>
<a name="l00027"></a>00027 <span class="comment">//extern &quot;C&quot; {</span>
<a name="l00028"></a>00028 <span class="comment">// #include &quot;MQTTClient.h&quot;</span>
<a name="l00029"></a>00029 <span class="comment">// #include &quot;MQTTClientPersistence.h&quot;</span>
<a name="l00030"></a>00030 <span class="comment">//}</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="preprocessor">#include &quot;<a class="code" href="async__client_8h.html" title="Declaration of MQTT async_client class.">async_client.h</a>&quot;</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;memory&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="keyword">namespace </span>mqtt {
<a name="l00038"></a>00038
<a name="l00040"></a>00040
<a name="l00045"></a><a class="code" href="classmqtt_1_1client.html">00045</a> <span class="keyword">class </span><a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> DFLT_QOS;
<a name="l00048"></a>00048
<a name="l00049"></a>00049 <span class="comment">//MQTTClient cli_;</span>
<a name="l00050"></a>00050
<a name="l00054"></a>00054 <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> cli_;
<a name="l00058"></a>00058 <span class="keywordtype">int</span> timeout_;
<a name="l00059"></a>00059
<a name="l00061"></a>00061 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>() =<span class="keyword">delete</span>;
<a name="l00062"></a>00062 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>(<span class="keyword">const</span> <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>&amp;) =<span class="keyword">delete</span>;
<a name="l00063"></a>00063 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>&amp; operator=(<span class="keyword">const</span> <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>&amp;) =<span class="keyword">delete</span>;
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="keyword">public</span>:
<a name="l00067"></a><a class="code" href="classmqtt_1_1client.html#a9d525663010133829d3a6d279f60de7f">00067</a> <span class="keyword">typedef</span> std::shared_ptr&lt;client&gt; <a class="code" href="classmqtt_1_1client.html#a9d525663010133829d3a6d279f60de7f" title="Smart pointer type for this object.">ptr_t</a>;
<a name="l00069"></a><a class="code" href="classmqtt_1_1client.html#a79b4ff7f06e5d5410cdf88484b564d0d">00069</a> <span class="keyword">typedef</span> <a class="code" href="classmqtt_1_1iasync__client.html#a058f9d82f67aac8415f8475ed63a5dad" title="Type for a collection of filters.">async_client::topic_filter_collection</a> <a class="code" href="classmqtt_1_1client.html#a79b4ff7f06e5d5410cdf88484b564d0d" title="Type for a collection of filters.">topic_filter_collection</a>;
<a name="l00071"></a><a class="code" href="classmqtt_1_1client.html#af8dcdca03f88e6ecb5c64561e77265ab">00071</a> <span class="keyword">typedef</span> <a class="code" href="classmqtt_1_1iasync__client.html#a2a86f5766c4b7f4f0c6cf01611380ccf" title="Type for a collection of QOS values.">async_client::qos_collection</a> <a class="code" href="classmqtt_1_1client.html#af8dcdca03f88e6ecb5c64561e77265ab" title="Type for a collection of QOS values.">qos_collection</a>;
<a name="l00072"></a>00072
<a name="l00079"></a>00079 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>(<span class="keyword">const</span> std::string&amp; serverURI, <span class="keyword">const</span> std::string&amp; clientId);
<a name="l00087"></a>00087 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>(<span class="keyword">const</span> std::string&amp; serverURI, <span class="keyword">const</span> std::string&amp; clientId,
<a name="l00088"></a>00088 <span class="keyword">const</span> std::string&amp; persistDir);
<a name="l00098"></a>00098 <a class="code" href="classmqtt_1_1client.html" title="Lightweight client for talking to an MQTT server using methods that block until an...">client</a>(<span class="keyword">const</span> std::string&amp; serverURI, <span class="keyword">const</span> std::string&amp; clientId,
<a name="l00099"></a>00099 <a class="code" href="classmqtt_1_1iclient__persistence.html" title="Represents a persistent data store, used to store outbound and inbound messages while...">iclient_persistence</a>* persistence);
<a name="l00104"></a>00104 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a69ebdd298caaa5be788a0625f2c55700" title="Close the client and releases all resource associated with the client.">close</a>();
<a name="l00108"></a>00108 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a8807675e81a186f09eba5b5f050d772c" title="Connects to an MQTT server using the default options.">connect</a>();
<a name="l00113"></a>00113 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a8807675e81a186f09eba5b5f050d772c" 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="l00117"></a>00117 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a3b0035bbb0a2ecd382a32862323540f8" title="Disconnects from the server.">disconnect</a>();
<a name="l00121"></a>00121 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a3b0035bbb0a2ecd382a32862323540f8" title="Disconnects from the server.">disconnect</a>(<span class="keywordtype">long</span> quiesceTimeout);
<a name="l00126"></a>00126 <span class="comment">//static std::string generateClientId();</span>
<a name="l00131"></a>00131 <span class="comment"></span> <span class="keyword">virtual</span> std::string <a class="code" href="classmqtt_1_1client.html#ad147f1d3bb2da1741e6f0eeba84f320c" title="Returns a randomly generated client identifier based on the current user&amp;#39;s login...">get_client_id</a>() <span class="keyword">const</span>;
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="comment">//Debug getDebug()</span>
<a name="l00134"></a>00134 <span class="comment">//Return a debug object that can be used to help solve problems.</span>
<a name="l00135"></a>00135
<a name="l00139"></a>00139 <span class="keyword">virtual</span> std::vector&lt;idelivery_token_ptr&gt; <a class="code" href="classmqtt_1_1client.html#a6decac54ce0b43453991964e1978fd97" title="Returns the delivery tokens for any outstanding publish operations.">get_pending_delivery_tokens</a>() <span class="keyword">const</span>;
<a name="l00144"></a>00144 <span class="keyword">virtual</span> std::string <a class="code" href="classmqtt_1_1client.html#ad7023de6695b304f9532a8efc44bbcb4" title="Returns the address of the server used by this client, as a URI.">get_server_uri</a>() <span class="keyword">const</span>;
<a name="l00149"></a>00149 <span class="keyword">virtual</span> <span class="keywordtype">long</span> <a class="code" href="classmqtt_1_1client.html#a8db3af55ae54802c5d5ef02ceac9c506" title="Return the maximum time to wait for an action to complete.">get_time_to_wait</a>() <span class="keyword">const</span>;
<a name="l00155"></a>00155 <span class="keyword">virtual</span> <a class="code" href="classmqtt_1_1topic.html" title="Represents a topic destination, used for publish/subscribe messaging.">topic</a> <a class="code" href="classmqtt_1_1client.html#ab13f7be6405ab2d8a6d9255aeee85014" title="Get a topic object which can be used to publish messages.">get_topic</a>(<span class="keyword">const</span> std::string&amp; tpc);
<a name="l00160"></a>00160 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classmqtt_1_1client.html#af37670f9792f932e273867a31f8cb2a5" title="Determines if this client is currently connected to the server.">is_connected</a>() <span class="keyword">const</span>;
<a name="l00170"></a>00170 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a6ecede0190eb852fdefaa5a3b560bd68" title="Publishes a message to a topic on the server and return once it is delivered.">publish</a>(<span class="keyword">const</span> std::string&amp; top, <span class="keyword">const</span> <span class="keywordtype">void</span>* payload, <span class="keywordtype">size_t</span> n,
<a name="l00171"></a>00171 <span class="keywordtype">int</span> qos, <span class="keywordtype">bool</span> retained);
<a name="l00177"></a>00177 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a6ecede0190eb852fdefaa5a3b560bd68" title="Publishes a message to a topic on the server and return once it is delivered.">publish</a>(<span class="keyword">const</span> std::string&amp; tpc, message_ptr msg);
<a name="l00183"></a>00183 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a49d9d64861e7f6bf436b212e26d3ba33" title="Sets the 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>&amp; cb);
<a name="l00188"></a>00188 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a40ee56f042da294015d013d56bc698ba" title="Set the maximum time to wait for an action to complete.">set_time_to_wait</a>(<span class="keywordtype">int</span> timeToWaitInMillis);
<a name="l00193"></a>00193 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a889ab68441badf3c5b4b5174ace82e4c" title="Subscribe to a topic, which may include wildcards using a QoS of 1.">subscribe</a>(<span class="keyword">const</span> std::string&amp; topicFilter);
<a name="l00198"></a>00198 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a889ab68441badf3c5b4b5174ace82e4c" title="Subscribe to a topic, which may include wildcards using a QoS of 1.">subscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1client.html#a79b4ff7f06e5d5410cdf88484b564d0d" title="Type for a collection of filters.">topic_filter_collection</a>&amp; topicFilters);
<a name="l00203"></a>00203 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a889ab68441badf3c5b4b5174ace82e4c" title="Subscribe to a topic, which may include wildcards using a QoS of 1.">subscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1client.html#a79b4ff7f06e5d5410cdf88484b564d0d" title="Type for a collection of filters.">topic_filter_collection</a>&amp; topicFilters,
<a name="l00204"></a>00204 <span class="keyword">const</span> <a class="code" href="classmqtt_1_1client.html#af8dcdca03f88e6ecb5c64561e77265ab" title="Type for a collection of QOS values.">qos_collection</a>&amp; qos);
<a name="l00210"></a>00210 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#a889ab68441badf3c5b4b5174ace82e4c" title="Subscribe to a topic, which may include wildcards using a QoS of 1.">subscribe</a>(<span class="keyword">const</span> std::string&amp; topicFilter, <span class="keywordtype">int</span> qos);
<a name="l00215"></a>00215 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#af237c77971882b968f9369a4f4e2422e" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> std::string&amp; topicFilter);
<a name="l00219"></a>00219 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmqtt_1_1client.html#af237c77971882b968f9369a4f4e2422e" title="Requests the server unsubscribe the client from a topic.">unsubscribe</a>(<span class="keyword">const</span> <a class="code" href="classmqtt_1_1client.html#a79b4ff7f06e5d5410cdf88484b564d0d" title="Type for a collection of filters.">topic_filter_collection</a>&amp; topicFilters);
<a name="l00220"></a>00220 };
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="keyword">typedef</span> <a class="code" href="classmqtt_1_1client.html#a9d525663010133829d3a6d279f60de7f" title="Smart pointer type for this object.">client::ptr_t</a> client_ptr;
<a name="l00223"></a>00223
<a name="l00225"></a>00225 <span class="comment">// end namespace mqtt</span>
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="preprocessor">#endif // __mqtt_client_h</span>
<a name="l00229"></a>00229 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 30 Apr 2014 for mqttpp by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>