Paho C++  1.0
The Paho MQTT C++ Client Library
 All Classes Files Functions Variables Typedefs Friends
iasync_client.h
Go to the documentation of this file.
1 
8 /*******************************************************************************
9  * Copyright (c) 2013-2016 Frank Pagliughi <fpagliughi@mindspring.com>
10  *
11  * All rights reserved. This program and the accompanying materials
12  * are made available under the terms of the Eclipse Public License v1.0
13  * and Eclipse Distribution License v1.0 which accompany this distribution.
14  *
15  * The Eclipse Public License is available at
16  * http://www.eclipse.org/legal/epl-v10.html
17  * and the Eclipse Distribution License is available at
18  * http://www.eclipse.org/org/documents/edl-v10.php.
19  *
20  * Contributors:
21  * Frank Pagliughi - initial implementation and documentation
22  *******************************************************************************/
23 
24 
25 #ifndef __mqtt_iasync_client_h
26 #define __mqtt_iasync_client_h
27 
28 #include "mqtt/types.h"
29 #include "mqtt/token.h"
30 #include "mqtt/delivery_token.h"
32 #include "mqtt/iaction_listener.h"
33 #include "mqtt/connect_options.h"
35 #include "mqtt/exception.h"
36 #include "mqtt/message.h"
37 #include "mqtt/callback.h"
38 #include <vector>
39 
40 namespace mqtt {
41 
43 
58 {
59  friend class token;
60  virtual void remove_token(token* tok) =0;
61 
62 public:
64  using qos_collection = std::vector<int>;
65 
69  virtual ~iasync_client() {}
77  virtual token_ptr connect() =0;
87  virtual token_ptr connect(connect_options options) =0;
102  virtual token_ptr connect(connect_options options, void* userContext,
103  iaction_listener& cb) =0;
114  virtual token_ptr connect(void* userContext, iaction_listener& cb) =0;
120  virtual token_ptr reconnect() =0;
127  virtual token_ptr disconnect() =0;
135  virtual token_ptr disconnect(disconnect_options opts) =0;
145  virtual token_ptr disconnect(int timeout) =0;
159  virtual token_ptr disconnect(int timeout, void* userContext, iaction_listener& cb) =0;
170  virtual token_ptr disconnect(void* userContext, iaction_listener& cb) =0;
175  virtual delivery_token_ptr get_pending_delivery_token(int msgID) const =0;
180  virtual std::vector<delivery_token_ptr> get_pending_delivery_tokens() const =0;
185  virtual string get_client_id() const =0;
189  virtual string get_server_uri() const =0;
193  virtual bool is_connected() const =0;
206  virtual delivery_token_ptr publish(string_ref topic,
207  const void* payload, size_t n,
208  int qos, bool retained) =0;
217  virtual delivery_token_ptr publish(string_ref topic,
218  const void* payload, size_t n) =0;
234  virtual delivery_token_ptr publish(string_ref topic,
235  const void* payload, size_t n,
236  int qos, bool retained,
237  void* userContext, iaction_listener& cb) =0;
249  virtual delivery_token_ptr publish(string_ref topic, binary_ref payload,
250  int qos, bool retained) =0;
258  virtual delivery_token_ptr publish(string_ref topic, binary_ref payload) =0;
267  virtual delivery_token_ptr publish(const_message_ptr msg) =0;
278  virtual delivery_token_ptr publish(const_message_ptr msg,
279  void* userContext, iaction_listener& cb) =0;
286  virtual void set_callback(callback& cb) =0;
290  virtual void disable_callbacks() = 0;
305  virtual token_ptr subscribe(const_string_collection_ptr topicFilters,
306  const qos_collection& qos) =0;
323  virtual token_ptr subscribe(const_string_collection_ptr topicFilters,
324  const qos_collection& qos,
325  void* userContext, iaction_listener& callback) =0;
338  virtual token_ptr subscribe(const string& topicFilter, int qos) =0;
355  virtual token_ptr subscribe(const string& topicFilter, int qos,
356  void* userContext, iaction_listener& callback) =0;
364  virtual token_ptr unsubscribe(const string& topicFilter) =0;
373  virtual token_ptr unsubscribe(const_string_collection_ptr topicFilters) =0;
386  virtual token_ptr unsubscribe(const_string_collection_ptr topicFilters,
387  void* userContext, iaction_listener& cb) =0;
399  virtual token_ptr unsubscribe(const string& topicFilter,
400  void* userContext, iaction_listener& cb) =0;
401 };
402 
404 // end namespace 'mqtt'
405 }
406 
407 #endif // __mqtt_iasync_client_h
408 
virtual void set_callback(callback &cb)=0
Sets a callback listener to use for events that happen asynchronously.
Basic types and type conversions for the Paho MQTT C++ library.
Provides a mechanism for tracking the completion of an asynchronous action.
Definition: iaction_listener.h:48
Implementation of the class 'disconnect_options'.
virtual token_ptr subscribe(const_string_collection_ptr topicFilters, const qos_collection &qos)=0
Subscribe to multiple topics, each of which may include wildcards.
Holds the set of options that control how the client connects to a server.
Definition: connect_options.h:46
Represents a topic destination, used for publish/subscribe messaging.
Definition: topic.h:42
Declaration of MQTT message class.
Declaration of MQTT callback class.
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.
virtual bool is_connected() const =0
Determines if this client is currently connected to the server.
Declaration of MQTT exception class.
virtual token_ptr reconnect()=0
Reconnects the client using options from the previous connect.
virtual void disable_callbacks()=0
Stops the callbacks.
virtual delivery_token_ptr get_pending_delivery_token(int msgID) const =0
Returns the delivery token for the specified message ID.
Enables an application to communicate with an MQTT server using non-blocking methods.
Definition: iasync_client.h:57
virtual std::vector< delivery_token_ptr > get_pending_delivery_tokens() const =0
Returns the delivery tokens for any outstanding publish operations.
virtual string get_server_uri() const =0
Returns the address of the server used by this client.
virtual token_ptr disconnect()=0
Disconnects from the server.
Declaration of MQTT iaction_listener class.
Declaration of MQTT connect_options class.
virtual token_ptr unsubscribe(const string &topicFilter)=0
Requests the server unsubscribe the client from a topic.
virtual string get_client_id() const =0
Returns the client ID used by this client.
Provides a mechanism for tracking the completion of an asynchronous action.
Definition: callback.h:41
Declaration of MQTT delivery_token class.
Declaration of MQTT iclient_persistence interface.
Provides a mechanism for tracking the completion of an asynchronous action.
Definition: token.h:49
virtual token_ptr connect()=0
Connects to an MQTT server using the default options.
std::vector< int > qos_collection
Type for a collection of QOS values.
Definition: iasync_client.h:64
virtual ~iasync_client()
Virtual destructor.
Definition: iasync_client.h:69
Options for disconnecting from an MQTT broker.
Definition: disconnect_options.h:37
Declaration of MQTT token class.