Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] paho c++ project status

Hey paho guys,
                        I started using the paho c++ library and i noticed that it builds with no errors but the build creates and empty library file. I cleaned up the make file and applied a patch that was not in git.

I do not have rights access to the repo to create a pull request so i created a patch. This patch is needed to get the build working properly again for new users.


--
Regards
Martin Naughton
From 718090af31d331e51a22624787a3a138828bb524 Mon Sep 17 00:00:00 2001
From: martin <blades2000@xxxxxxxxx>
Date: Sun, 15 Nov 2015 21:38:24 +0000
Subject: [PATCH] The build was creating an empty shared library which causing
 a lot of confusion for new users. Fixed the issues. Moved the header files to
 the include directory so it is easier to maintain and reference from the make
 file.

---
 Makefile                           |  16 +-
 include/mqtt/async_client.h        | 650 +++++++++++++++++++++++++++++++++++++
 include/mqtt/callback.h            |  74 +++++
 include/mqtt/client.h              | 229 +++++++++++++
 include/mqtt/connect_options.h     | 199 ++++++++++++
 include/mqtt/delivery_token.h      | 109 +++++++
 include/mqtt/exception.h           | 109 +++++++
 include/mqtt/iaction_listener.h    |  83 +++++
 include/mqtt/iclient_persistence.h | 133 ++++++++
 include/mqtt/ipersistable.h        | 140 ++++++++
 include/mqtt/message.h             | 183 +++++++++++
 include/mqtt/token.h               | 331 +++++++++++++++++++
 include/mqtt/topic.h               | 115 +++++++
 src/iclient_persistence.cpp        |   4 +-
 src/mqtt/async_client.h            | 650 -------------------------------------
 src/mqtt/callback.h                |  74 -----
 src/mqtt/client.h                  | 229 -------------
 src/mqtt/connect_options.h         | 199 ------------
 src/mqtt/delivery_token.h          | 109 -------
 src/mqtt/exception.h               | 109 -------
 src/mqtt/iaction_listener.h        |  83 -----
 src/mqtt/iclient_persistence.h     | 133 --------
 src/mqtt/ipersistable.h            | 140 --------
 src/mqtt/message.h                 | 183 -----------
 src/mqtt/token.h                   | 331 -------------------
 src/mqtt/topic.h                   | 115 -------
 26 files changed, 2368 insertions(+), 2362 deletions(-)
 create mode 100644 include/mqtt/async_client.h
 create mode 100644 include/mqtt/callback.h
 create mode 100644 include/mqtt/client.h
 create mode 100644 include/mqtt/connect_options.h
 create mode 100644 include/mqtt/delivery_token.h
 create mode 100644 include/mqtt/exception.h
 create mode 100644 include/mqtt/iaction_listener.h
 create mode 100644 include/mqtt/iclient_persistence.h
 create mode 100644 include/mqtt/ipersistable.h
 create mode 100644 include/mqtt/message.h
 create mode 100644 include/mqtt/token.h
 create mode 100644 include/mqtt/topic.h
 delete mode 100644 src/mqtt/async_client.h
 delete mode 100644 src/mqtt/callback.h
 delete mode 100644 src/mqtt/client.h
 delete mode 100644 src/mqtt/connect_options.h
 delete mode 100644 src/mqtt/delivery_token.h
 delete mode 100644 src/mqtt/exception.h
 delete mode 100644 src/mqtt/iaction_listener.h
 delete mode 100644 src/mqtt/iclient_persistence.h
 delete mode 100644 src/mqtt/ipersistable.h
 delete mode 100644 src/mqtt/message.h
 delete mode 100644 src/mqtt/token.h
 delete mode 100644 src/mqtt/topic.h

diff --git a/Makefile b/Makefile
index 3290d87..437220b 100644
--- a/Makefile
+++ b/Makefile
@@ -16,10 +16,12 @@ endif
 # ----- Directories -----
 
 LIB_DIR ?= lib
+SRC_DIR ?= src
 OBJ_DIR ?= obj
 INC_DIR ?= .
 
-PAHO_C_LIB ?= /home/fmp/static/opensrc/mqtt/paho/org.eclipse.paho.mqtt.c
+PAHO_C_LIB ?= ../org.eclipse.paho.mqtt.c
+PAHO_C_HEADERS = ./include 
 
 INC_DIRS += $(INC_DIR) $(PAHO_C_LIB)/src
 
@@ -41,18 +43,19 @@ TGT = $(LIB_DIR)/$(LIB)
 
 # ----- Sources -----
 
-SRCS += $(wildcard *.cpp)
+SRCS += $(wildcard $(SRC_DIR)/*.cpp)
 
 ifdef SRC_IGNORE
   SRCS := $(filter-out $(SRC_IGNORE),$(SRCS))
 endif
 
-OBJS := $(addprefix $(OBJ_DIR)/,$(SRCS:.cpp=.o))
+STRIP :=$(SRCS:$(SRC_DIR)/%=%)
+OBJS := $(addprefix $(OBJ_DIR)/,$(STRIP:.cpp=.o))
 DEPS := $(OBJS:.o=.dep)
 
 # ----- Compiler flags, etc -----
 
-CXXFLAGS += -std=c++0x
+CXXFLAGS += -std=c++0x -I$(PAHO_C_HEADERS)
 CPPFLAGS += -Wall -fPIC
 
 ifdef DEBUG
@@ -73,7 +76,7 @@ LDFLAGS := -g -shared -Wl,-soname,$(LIB_MAJOR_LINK) -L$(LIB_DIR)
 
 # ----- Compiler directives -----
 
-$(OBJ_DIR)/%.o: %.cpp
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
 	@echo $(CXX) $<
 	$(QUIET) $(COMPILE.cpp) $(OUTPUT_OPTION) $<
 
@@ -101,6 +104,7 @@ $(LIB_DIR)/$(LIB_MAJOR_LINK): $(TGT)
 dump:
 	@echo LIB=$(LIB)
 	@echo TGT=$(TGT)
+	@echo SRC_DIR=$(LIB_DIR)
 	@echo LIB_DIR=$(LIB_DIR)
 	@echo OBJ_DIR=$(OBJ_DIR)
 	@echo CFLAGS=$(CFLAGS)
@@ -111,6 +115,8 @@ dump:
 	@echo OBJS=$(OBJS)
 	@echo DEPS:$(DEPS)
 	@echo LIB_DEPS=$(LIB_DEPS)
+	@echo STRIP=$(STRIP)
+	@echo $(notdir $(SRCS))
 
 .PHONY: clean
 clean:
diff --git a/include/mqtt/async_client.h b/include/mqtt/async_client.h
new file mode 100644
index 0000000..3d6df96
--- /dev/null
+++ b/include/mqtt/async_client.h
@@ -0,0 +1,650 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file async_client.h
+/// Declaration of MQTT async_client class
+/// @date May 1, 2013
+/// @author Frank Pagliughi
+/////////////////////////////////////////////////////////////////////////////
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_async_client_h
+#define __mqtt_async_client_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/token.h"
+#include "mqtt/delivery_token.h"
+#include "mqtt/iclient_persistence.h"
+#include "mqtt/iaction_listener.h"
+#include "mqtt/connect_options.h"
+#include "mqtt/exception.h"
+#include "mqtt/message.h"
+#include "mqtt/callback.h"
+#include <string>
+#include <vector>
+#include <list>
+#include <memory>
+#include <stdexcept>
+
+namespace mqtt {
+
+const uint32_t		VERSION = 0x00010000;
+const std::string	VERSION_STR("mqttpp v. 0.1"),
+					COPYRIGHT("Copyright (c) 2013 Frank Pagliughi");
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * 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:
+ *
+ * @li connect
+ * @li publish
+ * @li subscribe
+ * @li unsubscribe
+ * @li disconnect
+ */
+class iasync_client
+{
+	friend class token;
+	virtual void remove_token(itoken* tok) =0;
+
+public:
+	/** Type for a collection of filters */
+	typedef std::vector<std::string> topic_filter_collection;
+	/** Type for a collection of QOS values */
+	typedef std::vector<int> qos_collection;
+
+	/**
+	 * Virtual destructor
+	 */
+	virtual ~iasync_client() {}
+	/**
+	 * Connects to an MQTT server using the default options.
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect() throw(exception, security_exception) =0;
+	/**
+	 * Connects to an MQTT server using the provided connect options. 
+	 * @param options 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(connect_options options) 
+							throw(exception, security_exception) =0;
+	/**
+	 * Connects to an MQTT server using the specified options.
+	 * 
+	 * @param options 
+	 * 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(connect_options options, void* userContext, 
+							   iaction_listener& cb) throw(exception, security_exception) =0;
+	/**
+	 *  
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(void* userContext, iaction_listener& cb)
+							throw(exception, security_exception) =0;
+	/**
+	 * Disconnects from the server. 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect() throw(exception) =0;
+	/**
+	 * Disconnects from the server.
+	 * 
+	 * @param quiesceTimeout 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(long quiesceTimeout) throw(exception) =0;
+	/**
+	 * Disconnects from the server.
+	 * 
+	 * @param quiesceTimeout 
+	 * @param userContext 
+	 * @param callback 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(long quiesceTimeout, void* userContext, iaction_listener& cb)
+						throw(exception) =0;
+	/**
+	 * Disconnects from the server.
+	 * @param userContext 
+	 * @param callback 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(void* userContext, iaction_listener& cb) 
+						throw(exception) =0;
+	/**
+	 * Returns the delivery token for the specified message ID.
+	 * @return idelivery_token
+	 */
+	virtual idelivery_token_ptr get_pending_delivery_token(int msgID) const =0;
+	/**
+	 * Returns the delivery tokens for any outstanding publish operations. 
+	 * @return idelivery_token[]
+	 */
+	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const =0;
+	/**
+	 * Returns the client ID used by this client.
+	 * @return std::string 
+	 */
+	virtual std::string get_client_id() const =0;
+	/**
+	 * Returns the address of the server used by this client.
+	 */
+	virtual std::string get_server_uri() const =0;
+	/**
+	 * Determines if this client is currently connected to the server.
+	 */
+	virtual bool is_connected() const =0;
+	/**
+	 * Publishes a message to a topic on the server
+	 * @param topic 
+	 * @param payload 
+	 * @param qos 
+	 * @param retained 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, const void* payload, 
+										size_t n, int qos, bool retained) 
+									throw(exception) =0;
+	/**
+	 * Publishes a message to a topic on the server 
+	 * @param topic 
+	 * @param payload 
+	 * @param qos 
+	 * @param retained 
+	 * @param userContext 
+	 * @param cb 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, 
+										const void* payload, size_t n,
+										int qos, bool retained, void* userContext, 
+										iaction_listener& cb) throw(exception) =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. 
+	 * 
+	 * @param topic 
+	 * @param message 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg)
+					throw(exception) =0;
+	/**
+	 * Publishes a message to a topic on the server. 
+	 * @param topic 
+	 * @param message 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg, 
+										void* userContext, iaction_listener& cb)
+					throw(exception) =0;
+	/**
+	 * Sets a callback listener to use for events that happen 
+	 * asynchronously. 
+	 * @param callback 
+	 */
+	virtual void set_callback(callback& cb) throw(exception) =0;
+	/**
+	 * Subscribe to multiple topics, each of which may include wildcards. 
+	 * @param topicFilters 
+	 * @param qos 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
+								 const qos_collection& qos) 
+					throw(std::invalid_argument,exception) =0;
+	/**
+	 * Subscribes to multiple topics, each of which may include wildcards. 
+	 * @param topicFilters 
+	 * @param qos 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
+								 const qos_collection& qos,
+								 void* userContext, iaction_listener& callback)
+					throw(std::invalid_argument,exception) =0;
+	/**
+	 * Subscribe to a topic, which may include wildcards. 
+	 * @param topicFilter 
+	 * @param qos 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos) 
+					throw(exception) =0;
+	/**
+	 * Subscribe to a topic, which may include wildcards. 
+	 * @param topicFilter 
+	 * @param qos 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos, 
+								 void* userContext, iaction_listener& callback)
+					throw(exception) =0;
+	/**
+	 * Requests the server unsubscribe the client from a topic. 
+	 * @param topicFilter 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const std::string& topicFilter) throw(exception) =0;
+	/**
+	 * Requests the server unsubscribe the client from one or more topics. 
+	 * @param string 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters) 
+					throw(exception) =0;
+	/**
+	 * Requests the server unsubscribe the client from one or more topics. 
+	 * @param string 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters, 
+								   void* userContext, iaction_listener& callback)
+					throw(exception) =0;
+	/**
+	 * Requests the server unsubscribe the client from a topics. 
+	 * @param topicFilter 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const std::string& topicFilter, 
+								   void* userContext, iaction_listener& callback)
+					throw(exception) =0;
+};
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Lightweight client for talking to an MQTT server using non-blocking
+ * methods that allow an operation to run in the background.
+ */
+class async_client : public virtual iasync_client
+{
+public:
+	/** Pointer type for this object */
+	typedef std::shared_ptr<async_client> ptr_t;
+
+private:
+	/** Lock guard type for this class */
+	typedef std::unique_lock<std::mutex> guard;
+
+	/** Object monitor mutex */
+	mutable std::mutex lock_;
+	/** The underlying C-lib client. */
+	MQTTAsync cli_;
+	/** The server URI string. */
+	std::string serverURI_;
+	/** The client ID string that we provided to the server. */
+	std::string clientId_;
+	/** A user persistence wrapper (if any) */
+	MQTTClient_persistence* persist_;
+	/** Callback supplied by the user (if any) */
+	callback* userCallback_;
+	/** A list of tokens that are in play */
+	std::list<itoken_ptr> pendingTokens_;
+	/** A list of delivery tokens that are in play */
+	std::list<idelivery_token_ptr> pendingDeliveryTokens_;
+
+	static void on_connection_lost(void *context, char *cause);
+	static int on_message_arrived(void* context, char* topicName, int topicLen, 
+								  MQTTAsync_message* msg);
+	static void on_delivery_complete(void* context, MQTTAsync_token tok);
+
+	/** Manage internal list of active tokens */
+	friend class token;
+	virtual void add_token(itoken_ptr tok);
+	virtual void add_token(idelivery_token_ptr tok);
+	virtual void remove_token(itoken* tok);
+	virtual void remove_token(itoken_ptr tok) { remove_token(tok.get()); }
+	void remove_token(idelivery_token_ptr tok) { remove_token(tok.get()); }
+
+	/** Memory management for C-style filter collections */
+	std::vector<char*> alloc_topic_filters(
+							const topic_filter_collection& topicFilters);
+	void free_topic_filters(std::vector<char*>& filts);
+
+	/**
+	 * Convenience function to get user callback safely. 
+	 * @return callback* 
+	 */
+	callback* get_callback() const {
+		guard g(lock_);
+		return userCallback_;
+	}
+
+	/** Non-copyable */
+	async_client() =delete;
+	async_client(const async_client&) =delete;
+	async_client& operator=(const async_client&) =delete;
+
+public:
+	/**
+	 * Create an async_client that can be used to communicate with an MQTT
+	 * server. 
+	 * This uses file-based persistence in the current working directory.
+	 * @param serverURI 
+	 * @param clientId 
+	 */
+	async_client(const std::string& serverURI, const std::string& clientId);
+	/**
+	 * Create an async_client that can be used to communicate with an MQTT
+	 * server. 
+	 * This uses file-based persistence in the specified directory. 
+	 * @param serverURI 
+	 * @param clientId 
+	 * @param persistDir 
+	 */
+	async_client(const std::string& serverURI, const std::string& clientId,
+				 const std::string& persistDir);
+	/**
+	 * Create an async_client that can be used to communicate with an MQTT
+	 * server. 
+	 * This allows the caller to specify a user-defined persistance object, 
+	 * or use no persistence. 
+	 * @param serverURI 
+	 * @param clientId 
+	 * @param persistence The user persistence structure. If this is null, 
+	 *  				  then no persistence is used.
+	 */
+	async_client(const std::string& serverURI, const std::string& clientId, 
+				 iclient_persistence* persistence);
+	/**
+	 * Destructor
+	 */
+	~async_client();
+	/**
+	 * Connects to an MQTT server using the default options.
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect() throw(exception, security_exception);
+	/**
+	 * Connects to an MQTT server using the provided connect options. 
+	 * @param options 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(connect_options options) throw(exception, security_exception);
+	/**
+	 * Connects to an MQTT server using the specified options.
+	 * 
+	 * @param options 
+	 * 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(connect_options options, void* userContext, 
+							   iaction_listener& cb) throw(exception, security_exception);
+	/**
+	 *  
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 * @throw exception 
+	 * @throw security_exception
+	 */
+	virtual itoken_ptr connect(void* userContext, iaction_listener& cb)
+							throw(exception, security_exception);
+	/**
+	 * Disconnects from the server. 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect() throw(exception) { return disconnect(0L); }
+	/**
+	 * Disconnects from the server.
+	 * 
+	 * @param quiesceTimeout 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(long quiesceTimeout) throw(exception);
+	/**
+	 * Disconnects from the server.
+	 * 
+	 * @param quiesceTimeout 
+	 * @param userContext 
+	 * @param callback 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(long quiesceTimeout, void* userContext, iaction_listener& cb)
+						throw(exception);
+	/**
+	 * Disconnects from the server.
+	 * @param userContext 
+	 * @param callback 
+	 * @return itoken_ptr
+	 */
+	virtual itoken_ptr disconnect(void* userContext, iaction_listener& cb) throw(exception) {
+		return disconnect(0L, userContext, cb);
+	}
+	/**
+	 * Returns the delivery token for the specified message ID.
+	 * @return idelivery_token
+	 */
+	virtual idelivery_token_ptr get_pending_delivery_token(int msgID) const;
+	/**
+	 * Returns the delivery tokens for any outstanding publish operations. 
+	 * @return idelivery_token[]
+	 */
+	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const;
+	/**
+	 * Returns the client ID used by this client.
+	 * @return std::string 
+	 */
+	virtual std::string get_client_id() const { return clientId_; }
+	/**
+	 * Returns the address of the server used by this client.
+	 */
+	virtual std::string get_server_uri() const { return serverURI_; }
+	/**
+	 * Determines if this client is currently connected to the server.
+	 */
+	virtual bool is_connected() const { return MQTTAsync_isConnected(cli_) != 0; }
+	/**
+	 * Publishes a message to a topic on the server
+	 * @param topic 
+	 * @param payload 
+	 * @param qos 
+	 * @param retained 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, const void* payload, 
+										size_t n, int qos, bool retained) throw(exception);
+	/**
+	 * Publishes a message to a topic on the server 
+	 * @param topic 
+	 * @param payload 
+	 * @param qos 
+	 * @param retained 
+	 * @param userContext 
+	 * @param cb 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, 
+										const void* payload, size_t n,
+										int qos, bool retained, void* userContext, 
+										iaction_listener& cb) throw(exception);
+	/**
+	 * 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. 
+	 * 
+	 * @param topic 
+	 * @param message 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg)
+					throw(exception);
+	/**
+	 * Publishes a message to a topic on the server. 
+	 * @param topic 
+	 * @param message 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return idelivery_token 
+	 */
+	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg, 
+										void* userContext, iaction_listener& cb)
+					throw(exception);
+	/**
+	 * Sets a callback listener to use for events that happen 
+	 * asynchronously. 
+	 * @param callback 
+	 */
+	virtual void set_callback(callback& cb) throw(exception);
+	/**
+	 * Subscribe to multiple topics, each of which may include wildcards. 
+	 * @param topicFilters 
+	 * @param qos 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
+								 const qos_collection& qos) 
+					throw(std::invalid_argument,exception);
+	/**
+	 * Subscribes to multiple topics, each of which may include wildcards. 
+	 * @param topicFilters 
+	 * @param qos 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
+								 const qos_collection& qos,
+								 void* userContext, iaction_listener& callback)
+					throw(std::invalid_argument,exception);
+	/**
+	 * Subscribe to a topic, which may include wildcards. 
+	 * @param topicFilter 
+	 * @param qos 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos) 
+					throw(exception);
+	/**
+	 * Subscribe to a topic, which may include wildcards. 
+	 * @param topicFilter 
+	 * @param qos 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos, 
+								 void* userContext, iaction_listener& callback)
+					throw(exception);
+	/**
+	 * Requests the server unsubscribe the client from a topic. 
+	 * @param topicFilter 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const std::string& topicFilter) throw(exception);
+	/**
+	 * Requests the server unsubscribe the client from one or more topics. 
+	 * @param string 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters) 
+					throw(exception);
+	/**
+	 * Requests the server unsubscribe the client from one or more topics. 
+	 * @param string 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters, 
+								   void* userContext, iaction_listener& callback)
+					throw(exception);
+	/**
+	 * Requests the server unsubscribe the client from a topics. 
+	 * @param topicFilter 
+	 * @param userContext 
+	 * @param callback 
+	 * 
+	 * @return bool 
+	 */
+	virtual itoken_ptr unsubscribe(const std::string& topicFilter, 
+								   void* userContext, iaction_listener& callback)
+					throw(exception);
+};
+
+/**
+ * Shared pointer to an asynchronous MQTT client object.
+ */
+typedef async_client::ptr_t async_client_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_async_client_h
+
diff --git a/include/mqtt/callback.h b/include/mqtt/callback.h
new file mode 100644
index 0000000..a2e7f0e
--- /dev/null
+++ b/include/mqtt/callback.h
@@ -0,0 +1,74 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file callback.h
+/// Declaration of MQTT callback class
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_callback_h
+#define __mqtt_callback_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/delivery_token.h"
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the completion of an asynchronous 
+ * action. 
+ */
+class callback
+{
+public:
+	typedef std::shared_ptr<callback> ptr_t;
+	/**
+	 * This method is called when the connection to the server is lost.
+	 * @param cause 
+	 */
+	virtual void connection_lost(const std::string& cause) =0;
+	/**
+	 * This method is called when a message arrives from the server. 
+	 * @param topic
+	 * @param msg 
+	 */
+	virtual void message_arrived(const std::string& topic, message_ptr msg) =0;
+	/**
+	 * Called when delivery for a message has been completed, and all 
+	 * acknowledgments have been received.
+	 * @param token 
+	 */
+	virtual void delivery_complete(idelivery_token_ptr tok) =0;
+};
+
+typedef callback::ptr_t callback_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_callback_h
+
diff --git a/include/mqtt/client.h b/include/mqtt/client.h
new file mode 100644
index 0000000..41a7b13
--- /dev/null
+++ b/include/mqtt/client.h
@@ -0,0 +1,229 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file client.h 
+/// Declaration of MQTT client class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_client_h
+#define __mqtt_client_h
+
+//extern "C" {
+//	#include "MQTTClient.h"
+//	#include "MQTTClientPersistence.h"
+//}
+
+#include "async_client.h"
+
+#include <string>
+#include <memory>
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Lightweight client for talking to an MQTT server using methods that block
+ * until an operation completes.
+ */
+class client
+{
+	static const int DFLT_QOS;
+
+	//MQTTClient cli_;
+
+	/**
+	 * The actual client
+	 */
+	async_client cli_;
+	/**
+	 * The longest amount of time to wait for an operation (in milliseconds)
+	 */
+	int timeout_;
+
+	/** Non-copyable */
+	client() =delete;
+	client(const async_client&) =delete;
+	client& operator=(const async_client&) =delete;
+
+public:
+	/** Smart pointer type for this object */
+	typedef std::shared_ptr<client> ptr_t;
+	/** Type for a collection of filters */
+	typedef async_client::topic_filter_collection topic_filter_collection;
+	/** Type for a collection of QOS values */
+	typedef async_client::qos_collection qos_collection;
+
+	/**
+	 * Create a client that can be used to communicate with an MQTT server.
+	 * This uses file-based persistence in the current working directory.
+	 * @param serverURI 
+	 * @param clientId 
+	 */
+	client(const std::string& serverURI, const std::string& clientId);
+	/**
+	 * Create a client that can be used to communicate with an MQTT server.
+	 * This uses file-based persistence in the specified directory. 
+	 * @param serverURI 
+	 * @param clientId 
+	 * @param persistDir 
+	 */
+	client(const std::string& serverURI, const std::string& clientId,
+		   const std::string& persistDir);
+	/**
+	 * Create a client that can be used to communicate with an MQTT server.
+	 * This allows the caller to specify a user-defined persistance object, 
+	 * or use no persistence. 
+	 * @param serverURI 
+	 * @param clientId 
+	 * @param persistence The user persistence structure. If this is null, 
+	 *  				  then no persistence is used.
+	 */
+	client(const std::string& serverURI, const std::string& clientId, 
+		   iclient_persistence* persistence);
+	/**
+	 * Close the client and releases all resource associated with the 
+	 * client. 
+	 */
+	virtual void close();
+	/**
+	 * Connects to an MQTT server using the default options.
+	 */
+	virtual void connect();
+	/**
+	 * Connects to an MQTT server using the specified options.
+	 * @param options 
+	 */
+	virtual void connect(connect_options options);
+	/**
+	 * Disconnects from the server.
+	 */
+	virtual void disconnect();
+	/**
+	 * Disconnects from the server.
+	 */
+	virtual void disconnect(long quiesceTimeout);
+	/**
+	 * Returns a randomly generated client identifier based on the current 
+	 * user's login name and the system time. 
+	 */
+	//static std::string generateClientId();
+	/**
+	 * Returns the client ID used by this client.
+	 * @return std::string 
+	 */
+	virtual std::string get_client_id() const;
+
+	//Debug 	getDebug()
+	//Return a debug object that can be used to help solve problems.
+
+	/**
+	 * Returns the delivery tokens for any outstanding publish operations.
+	 */
+	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const;
+	/**
+	 * Returns the address of the server used by this client, as a URI.
+	 * @return std::string 
+	 */
+	virtual std::string get_server_uri() const;
+	/**
+	 * Return the maximum time to wait for an action to complete. 
+	 * @return long 
+	 */
+	virtual long get_time_to_wait() const;
+	/**
+	 * Get a topic object which can be used to publish messages.
+	 * @param tpc 
+	 * @return topic 
+	 */
+	virtual topic get_topic(const std::string& tpc);
+	/**
+	 * Determines if this client is currently connected to the server. 
+	 * @return bool 
+	 */
+	virtual bool is_connected() const;
+	/**
+	 * Publishes a message to a topic on the server and return once it is 
+	 * delivered. 
+	 * @param topic 
+	 * @param payload 
+	 * @param n 
+	 * @param qos 
+	 * @param retained 
+	 */
+	virtual void publish(const std::string& top, const void* payload, size_t n,
+						 int qos, bool retained);
+	/**
+	 * Publishes a message to a topic on the server. 
+	 * @param tpc 
+	 * @param msg 
+	 */
+	virtual void publish(const std::string& tpc, message_ptr msg);
+	/**
+	 * Sets the callback listener to use for events that happen 
+	 * asynchronously.
+	 * @param callback 
+	 */
+	virtual void set_callback(callback& cb);
+	/**
+	 * Set the maximum time to wait for an action to complete 
+	 * @param timeToWaitInMillis 
+	 */
+	virtual void set_time_to_wait(int timeToWaitInMillis);
+	/**
+	 * Subscribe to a topic, which may include wildcards using a QoS of 1. 
+	 * @param topicFilter 
+	 */
+	virtual void subscribe(const std::string& topicFilter);
+	/**
+	 * Subscribes to a one or more topics, which may include wildcards using
+	 * a QoS of 1.
+	 */
+	virtual void subscribe(const topic_filter_collection& topicFilters);
+	/**
+	 * Subscribes to multiple topics, each of which may include wildcards.
+	 * @param string 
+	 */
+	virtual void subscribe(const topic_filter_collection& topicFilters, 
+						   const qos_collection& qos);
+	/**
+	 * Subscribe to a topic, which may include wildcards.
+	 * @param topicFilter 
+	 * @param qos 
+	 */
+	virtual void subscribe(const std::string& topicFilter, int qos);
+	/**
+	 * Requests the server unsubscribe the client from a topic. 
+	 * @param topicFilter 
+	 */
+	virtual void unsubscribe(const std::string& topicFilter);
+	/**
+	 * Requests the server unsubscribe the client from one or more topics.
+	 */
+	virtual void unsubscribe(const topic_filter_collection& topicFilters);
+};
+
+typedef client::ptr_t client_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_client_h
+
diff --git a/include/mqtt/connect_options.h b/include/mqtt/connect_options.h
new file mode 100644
index 0000000..ed19885
--- /dev/null
+++ b/include/mqtt/connect_options.h
@@ -0,0 +1,199 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file connect_options.h 
+/// Declaration of MQTT connect_options class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_connect_options_h
+#define __mqtt_connect_options_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/message.h"
+#include "mqtt/topic.h"
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace mqtt {
+
+class async_client;
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Holds the set of options that control how the client connects to a 
+ * server. 
+ */
+class connect_options
+{
+	/** The underlying C connection options */
+	MQTTAsync_connectOptions opts_;
+
+	/** The client has special access */
+	friend class async_client;
+
+public:
+	/**
+	 * Smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<connect_options> ptr_t;
+	/**
+	 * Constructs a new MqttConnectOptions object using the default values.
+	 */
+	connect_options() : opts_( MQTTAsync_connectOptions_initializer ) {}
+	/**
+	 * Returns the connection timeout value. 
+	 * @return int 
+	 */
+	int get_connection_timeout() const;
+
+	//java.util.Properties getDebug()
+           
+	/**
+	 * Returns the "keep alive" interval.
+	 * @return int 
+	 */
+	int get_keep_alive_interval() const {
+		return opts_.keepAliveInterval;
+	}
+	/**
+	 * Returns the password to use for the connection.
+	 * @return std::string 
+	 */
+	std::string get_password() const {
+		return std::string(opts_.password);
+	}
+	/**
+	 * Returns the socket factory that will be used when connecting, or null 
+	 * if one has not been set.
+	 */
+	//javax.net.SocketFactory get_socket_factory();
+	/**
+	 * Returns the SSL properties for the connection.
+	 */
+	//java.util.Properties get_ssl_properties();
+	/**
+	 * Returns the user name to use for the connection.
+	 * @return std::string 
+	 */
+	std::string get_user_name() const { 
+		return std::string(opts_.username);
+	}
+	/**
+	 * Returns the topic to be used for last will and testament (LWT).
+	 * @return std::string 
+	 */
+	std::string get_will_destination() const;
+	/**
+	 * Returns the message to be sent as last will and testament (LWT).
+	 * @return MqttMessage 
+	 */
+	message get_will_message() const;
+	/**
+	 * Returns whether the server should remember state for the client 
+	 * across reconnects.
+	 * @return bool 
+	 */
+	bool is_clean_session() const { return opts_.cleansession != 0; }
+	/**
+	 * Sets whether the server should remember state for the client across 
+	 * reconnects. 
+	 * @param cleanSession 
+	 */
+	void set_clean_session(bool cleanSession) {
+		opts_.cleansession = (cleanSession) ? (!0) : 0;
+	}
+	/**
+	 * Sets the connection timeout value.
+	 * @param timeout 
+	 */
+	void set_connection_timeout(int timeout) {
+		opts_.connectTimeout = timeout;
+	}
+	/**
+	 * Sets the "keep alive" interval. 
+	 * @param keepAliveInterval 
+	 */
+	void set_keep_alive_interval(int keepAliveInterval) {
+		opts_.keepAliveInterval = keepAliveInterval;
+	}
+	/**
+	 * Sets the password to use for the connection.
+	 */
+	void set_password(const std::string& password);
+	/**
+	 * Sets the SocketFactory to use.
+	 */
+	//void set_socket_factory(javax.net.SocketFactory socketFactory)
+	/**
+	 * Sets the SSL properties for the connection.
+	 */
+	//void set_ssl_properties(java.util.Properties props);
+	/**
+	 * Sets the user name to use for the connection.
+	 * @param userName 
+	 */
+	void set_user_name(const std::string& userName);
+	/**
+	 * Sets the "Last Will and Testament" (LWT) for the connection.
+	 * @param top 
+	 * @param payload 
+	 * @param n 
+	 * @param qos 
+	 * @param retained 
+	 */
+	void set_will(const topic& top, void* payload, size_t n, int qos, bool retained) {
+		set_will(top.get_name(), payload, n, qos, retained);
+	}
+	/**
+	 * Sets the "Last Will and Testament" (LWT) for the connection.
+	 * @param top 
+	 * @param payload 
+	 * @param n 
+	 * @param qos 
+	 * @param retained 
+	 */
+	void set_will(const std::string& top, void* payload, size_t n, int qos, bool retained);
+	/**
+	 * Sets up the will information, based on the supplied parameters. 
+	 * @param top 
+	 * @param msg 
+	 * @param qos 
+	 * @param retained 
+	 */
+	/*protected*/ void set_will(const std::string& top, message msg, int qos, bool retained);
+
+	std::string to_str() const;
+};
+
+/**
+ * Shared pointer to the connection options class.
+ */
+typedef connect_options::ptr_t connect_options_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_connect_options_h
+
diff --git a/include/mqtt/delivery_token.h b/include/mqtt/delivery_token.h
new file mode 100644
index 0000000..fc52249
--- /dev/null
+++ b/include/mqtt/delivery_token.h
@@ -0,0 +1,109 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file delivery_token.h 
+/// Declaration of MQTT delivery_token class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_delivery_token_h
+#define __mqtt_delivery_token_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/token.h"
+#include "mqtt/message.h"
+#include <memory>
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the delivery of a message.
+ */
+class idelivery_token : public virtual itoken
+{
+public:
+	typedef std::shared_ptr<idelivery_token> ptr_t;
+	/**
+	 * Returns the message associated with this token. 
+	 * @return The message associated with this token.
+	 */
+	virtual message_ptr get_message() const =0;          
+};
+
+typedef idelivery_token::ptr_t idelivery_token_ptr;
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism to track the delivery progress of a message.
+ * Used to track the the delivery progress of a message when a publish is
+ * executed in a non-blocking manner (run in the background) action.
+ */
+class delivery_token : public virtual idelivery_token,
+						public token
+{
+	/** The message being tracked. */
+	message_ptr msg_;
+
+	/** Client has special access. */
+	friend class async_client;
+
+	/**
+	 * Sets the message that this token correspn
+	 * @param msg 
+	 */
+	void set_message(message_ptr msg) { msg_ = msg; }
+
+public:
+	/**
+	 * Smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<delivery_token> ptr_t;
+
+	delivery_token(iasync_client& cli) : token(cli) {}
+
+	delivery_token(iasync_client& cli, const std::string& topic) : token(cli, topic) {}
+
+	delivery_token(iasync_client& cli, const std::vector<std::string>& topics) 
+					: token(cli, topics) {}
+
+	//delivery_token(const std::string& logContext);
+
+	/**
+	 * Returns the message associated with this token.
+	 * @return message 
+	 */
+	virtual message_ptr get_message() const { return msg_; }
+};
+
+/**
+ * Shared pointer to a delivery_token.
+ */
+typedef delivery_token::ptr_t delivery_token_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_delivery_token_h
+
diff --git a/include/mqtt/exception.h b/include/mqtt/exception.h
new file mode 100644
index 0000000..301c8b8
--- /dev/null
+++ b/include/mqtt/exception.h
@@ -0,0 +1,109 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file exception.h 
+/// Declaration of MQTT exception class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_exception_h
+#define __mqtt_exception_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <exception>
+#include <stdexcept>
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the completion of an asynchronous 
+ * action. 
+ */
+class exception : public std::runtime_error
+{
+	int code_;
+
+public:
+	explicit exception(int reasonCode) : std::runtime_error("mqtt::exception"),
+											code_(reasonCode) {}
+	/**
+	 * Returns the underlying cause of this exception, if available.
+	 */
+	//java.lang.Throwable 	getCause()
+	/**
+	 * Returns the detail message for this exception.
+	 */
+	std::string get_message()  const { return std::string(what()); }
+	/**
+	 * Returns the reason code for this exception.
+	 */
+	int get_reason_code() const { return code_; }
+	/**
+	 * Returns a String representation of this exception. 
+	 * @return std::tring 
+	 */
+	std::string to_str() const { return std::string(what()); }
+	/**
+	 * Returns an explanatory string for the exception.
+	 * @return const char* 
+	 */
+	virtual const char* what() const noexcept {
+		return std::exception::what();
+	}
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * This exception is thrown by the implementor of the persistence interface
+ * if there is a problem reading or writing persistent data.
+ */
+class persistence_exception : public exception
+{
+public:
+	// TODO: Define "reason codes"
+	persistence_exception() : exception(MQTTCLIENT_PERSISTENCE_ERROR) {}
+	persistence_exception(int reasonCode) : exception(reasonCode) {}
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Thrown when a client is not authorized to perform an operation, or if
+   there is a problem with the security configuration.
+ */
+class security_exception : public exception
+{
+public:
+	security_exception(int reasonCode) : exception(reasonCode) {}
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_token_h
+
diff --git a/include/mqtt/iaction_listener.h b/include/mqtt/iaction_listener.h
new file mode 100644
index 0000000..e54cf1c
--- /dev/null
+++ b/include/mqtt/iaction_listener.h
@@ -0,0 +1,83 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file iaction_listener.h 
+/// Declaration of MQTT iaction_listener class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_iaction_listener_h
+#define __mqtt_iaction_listener_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace mqtt {
+	
+class itoken;
+ 	
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the completion of an asynchronous 
+ * action. 
+ *  
+ * A listener is registered on a token and that token is associated with
+ * an action like connect or publish. When used with tokens on the
+ * async_client the listener will be called back on the MQTT client's
+ * thread. The listener will be informed if the action succeeds or fails. It
+ * is important that the listener returns control quickly otherwise the
+ * operation of the MQTT client will be stalled.
+ */
+class iaction_listener
+{
+public:
+	/**
+	 * Shared pointer to this class.
+	 */
+	typedef std::shared_ptr<iaction_listener> ptr_t;
+	/**
+	 * Virtual base destructor.
+	 */
+	virtual ~iaction_listener() {}
+	/**
+	 * This method is invoked when an action fails. 
+	 * @param asyncActionToken 
+	 * @param exc 
+	 */
+	virtual void on_failure(const itoken& asyncActionToken /*, java.lang.Throwable exc*/) =0;
+	/**
+	 * This method is invoked when an action has completed successfully. 
+	 * @param asyncActionToken 
+	 */
+	virtual void on_success(const itoken& asyncActionToken) =0;
+};
+
+typedef iaction_listener::ptr_t iaction_listener_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_iaction_listener_h
+
diff --git a/include/mqtt/iclient_persistence.h b/include/mqtt/iclient_persistence.h
new file mode 100644
index 0000000..f44dd9a
--- /dev/null
+++ b/include/mqtt/iclient_persistence.h
@@ -0,0 +1,133 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file iclient_persistence.h 
+/// Declaration of MQTT iclient_persistence interface
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_iclient_persistence_h
+#define __mqtt_iclient_persistence_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/ipersistable.h"
+#include <string>
+#include <memory>
+#include <vector> 
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * Represents a persistent data store, used to store outbound and inbound
+ * messages while they are in flight, enabling delivery to the QoS
+ * specified. You can specify an implementation of this interface using
+ * client::client(string, string, iclient_persistence), which the
+ * client will use to persist QoS 1 and 2 messages.
+ *
+ * If the methods defined throw the MqttPersistenceException then the state
+ * of the data persisted should remain as prior to the method being called.
+ * For example, if put(string, persistable) throws an exception at any
+ * point then the data will be assumed to not be in the persistent store.
+ * Similarly if remove(string) throws an exception then the data will be
+ * assumed to still be held in the persistent store.
+ *
+ * It is up to the persistence interface to log any exceptions or error
+ * information which may be required when diagnosing a persistence failure.
+ */
+class iclient_persistence
+{
+	friend class iasync_client;
+
+public:
+
+	/** C-callbacks  */
+	static int persistence_open(void** handle, const char* clientID, const char* serverURI, void* context);
+	static int persistence_close(void* handle); 
+	static int persistence_put(void* handle, char* key, int bufcount, char* buffers[], int buflens[]);
+	static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
+	static int persistence_remove(void* handle, char* key);
+	static int persistence_keys(void* handle, char*** keys, int* nkeys);
+	static int persistence_clear(void* handle);
+	static int persistence_containskey(void* handle, char* key);
+
+public:
+	/**
+	 * Smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<iclient_persistence> ptr_t;
+	/**
+	 * Virtual destructor.
+	 */
+	virtual ~iclient_persistence() {}
+	/** 
+	 * Initialise the persistent store.
+	 */          
+	virtual void open(const std::string& clientId, const std::string& serverURI) =0;
+	/**
+	 * Close the persistent store that was previously opened.
+	 */
+	virtual void close() =0;
+	/**
+	 * Clears persistence, so that it no longer contains any persisted data.
+	 */
+	virtual void clear() =0;
+	/**
+	 * Returns whether or not data is persisted using the specified key. 
+	 * @param key 
+	 * @return bool 
+	 */
+	virtual bool contains_key(const std::string& key) =0;
+	/**
+	 * Gets the specified data out of the persistent store.
+	 * @param key 
+	 * @return persistable 
+	 */
+	virtual ipersistable_ptr get(const std::string& key) const =0;
+	/**
+	 * Returns an Enumeration over the keys in this persistent data store.
+	 */
+	virtual std::vector<std::string> keys() const =0;
+	/**
+	 * Puts the specified data into the persistent store.
+	 * @param key 
+	 * @param persistable 
+	 */
+	virtual void put(const std::string& key, ipersistable_ptr persistable) =0;
+	/**
+	 * Remove the data for the specified key. 
+	 * @param key 
+	 */
+	virtual void remove(const std::string& key) =0;
+};
+
+/**
+ * Shared pointer to a persistence client.
+ */
+typedef std::shared_ptr<iclient_persistence> iclient_persistence_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_iclient_persistence_h
+
diff --git a/include/mqtt/ipersistable.h b/include/mqtt/ipersistable.h
new file mode 100644
index 0000000..51d7624
--- /dev/null
+++ b/include/mqtt/ipersistable.h
@@ -0,0 +1,140 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file ipersistable.h 
+/// Declaration of MQTT ipersistable interface.
+/// @date May 24, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_ipersistable_h
+#define __mqtt_ipersistable_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include <string>
+#include <memory>
+#include <vector>
+#include <stdexcept> 
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Represents an object used to pass data to be persisted across the
+ * MqttClientPersistence interface.
+ *
+ * When data is passed across the interface the header and payload are
+ * separated, so that unnecessary message copies may be avoided. For
+ * example, if a 10 MB payload was published it would be inefficient to
+ * create a byte array a few bytes larger than 10 MB and copy the MQTT
+ * message header and payload into a contiguous byte array.
+ *
+ * When the request to persist data is made a separate byte array and offset
+ * is passed for the header and payload. Only the data between offset and
+ * length need be persisted. So for example, a message to be persisted
+ * consists of a header byte array starting at offset 1 and length 4, plus a
+ * payload byte array starting at offset 30 and length 40000. There are
+ * three ways in which the persistence implementation may return data to the
+ * client on recovery:
+ *
+ * @li
+ * It could return the data as it was passed in originally, with the same
+ * byte arrays and offsets.
+ *
+ * @li
+ * It could safely just persist and return the bytes from the offset for the
+ * specified length. For example, return a header byte array with offset 0
+ * and length 4, plus a payload byte array with offset 0 and length 40000
+ *
+ * @li
+ * It could return the header and payload as a contiguous byte array with
+ * the header bytes preceeding the payload. The contiguous byte array should
+ * be set as the header byte array, with the payload byte array being null.
+ * For example, return a single byte array with offset 0 and length 40004.
+ * This is useful when recovering from a file where the header and payload
+ * could be written as a contiguous stream of bytes.
+ */
+
+class ipersistable
+{
+public:
+	/**
+	 * Smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<ipersistable> ptr_t;
+	/**
+	 * Virtual destructor
+	 */
+	virtual ~ipersistable() {}
+	/**
+	 * Returns the header bytes in an array. 
+	 * @return std::vector<uint8_t> 
+	 */
+	virtual const uint8_t* get_header_bytes() const =0;
+	/**
+	 * Returns the header bytes in an array. 
+	 * @return std::vector<uint8_t> 
+	 */
+	virtual std::vector<uint8_t> get_header_byte_arr() const =0;
+	/**
+	 * Returns the length of the header. 
+	 * @return int 
+	 */
+	virtual size_t get_header_length() const =0;
+	/**
+	 * Returns the offset of the header within the byte array returned by 
+	 * get_header_bytes(). 
+	 * @return int 
+	 */
+	virtual size_t get_header_offset() const =0;
+	/**
+	 * Returns the payload bytes in an array.
+	 * @return std::vector<uint8_t> 
+	 */
+	virtual const uint8_t* get_payload_bytes() const =0;
+	/**
+	 * Returns the payload bytes in an array.
+	 * @return std::vector<uint8_t> 
+	 */
+	virtual std::vector<uint8_t> get_payload_byte_arr() const =0;
+	/**
+	 * Returns the length of the payload.
+	 * @return int 
+	 */
+	virtual size_t get_payload_length() const =0;
+	/**
+	 * Returns the offset of the payload within the byte array returned by 
+	 * get_payload_bytes(). 
+	 * 
+	 * @return int 
+	 */
+	virtual size_t get_payload_offset() const =0;
+};
+
+typedef ipersistable::ptr_t ipersistable_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_ipersistable_h
+
+
diff --git a/include/mqtt/message.h b/include/mqtt/message.h
new file mode 100644
index 0000000..7653619
--- /dev/null
+++ b/include/mqtt/message.h
@@ -0,0 +1,183 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file message.h 
+/// Declaration of MQTT message class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_message_h
+#define __mqtt_message_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include <string>
+#include <memory>
+#include <stdexcept> 
+
+namespace mqtt {
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * An MQTT message holds the application payload and options specifying how 
+ * the message is to be delivered The message includes a "payload" (the body 
+ * of the message) represented as a byte array. 
+ */
+class message
+{
+	/** The underlying C message struct */
+	MQTTAsync_message msg_;
+
+	/** The client has special access. */
+	friend class async_client;
+
+	/**
+	 * Set the dup flag in the underlying message 
+	 * @param dup 
+	 */
+	void set_duplicate(bool dup) { msg_.dup = (dup) ? (!0) : 0; }
+	/**
+	 * Copies the specified payload into this object.
+	 * @param payload 
+	 * @param len 
+	 */
+	void copy_payload(const void* payload, size_t len);
+
+public:
+	/**
+	 * Smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<message> ptr_t;
+	/**
+	 * Constructs a message with an empty payload, and all other values set
+	 * to defaults.
+	 */
+	message();
+	/**
+	 * Constructs a message with the specified array as a payload, and all 
+	 * other values set to defaults. 
+	 */
+	message(const void* payload, size_t len);
+	/**
+	 * Constructs a message with the specified string as a payload, and 
+	 * all other values set to defaults.
+	 */
+	message(const std::string& payload);
+	/**
+	 * Constructs a message as a copy of the message structure.
+	 */
+	message(const MQTTAsync_message& msg);
+	/**
+	 * Constructs a message as a copy of the other message.
+	 */
+	message(const message& other);
+	/**
+	 * Moves the other message to this one.
+	 */
+	message(message&& other);
+	/**
+	 * Destroys a message and frees all associated resources.
+	 */
+	~message();
+	/**
+	 * Copies another message to this one. 
+	 * @param rhs The other message. 
+	 * @return A reference to this message.
+	 */
+	message& operator=(const message& rhs);
+	/**
+	 * Moves another message to this one. 
+	 * @param rhs The other message. 
+	 * @return A reference to this message.
+	 */
+	message& operator=(message&& rhs);
+	/**
+	 * Clears the payload, resetting it to be empty.
+	 */
+	void clear_payload();
+	/**
+	 * Gets the payload
+	 */
+	std::string get_payload() const;
+	/**
+	 * Returns the quality of service for this message.
+	 * @return The quality of service for this message.
+	 */
+	int get_qos() const { return msg_.qos; }
+	/**
+	 * Returns whether or not this message might be a duplicate of one which 
+	 * has already been received. 
+	 * @return bool 
+	 */
+	bool is_duplicate() const { return msg_.dup != 0; }
+	/**
+	 * Returns whether or not this message should be/was retained by the 
+	 * server.
+	 * @return bool 
+	 */
+	bool is_retained() const { return msg_.retained != 0; }
+	/**
+	 * Sets the payload of this message to be the specified byte array.
+	 */
+	void set_payload(const void* payload, size_t n);
+	/**
+	 * Sets the payload of this message to be the specified string.
+	 */
+	void set_payload(const std::string& payload);
+	/**
+	 * Sets the quality of service for this message.
+	 * 
+	 * @param qos 
+	 */
+	void set_qos(int qos) throw(std::invalid_argument) {
+		validate_qos(qos); 
+		msg_.qos = qos;
+	}
+	/**
+	 * Whether or not the publish message should be retained by the 
+	 * messaging engine. 
+	 * @param retained 
+	 */
+	void set_retained(bool retained) { msg_.retained = (retained) ? (!0) : 0; }
+	/**
+	 * Returns a string representation of this messages payload. 
+	 * @return std::string 
+	 */
+	std::string to_str() const { return get_payload(); }
+	/**
+	 * Determines if the QOS value is a valid one.
+	 * @param qos The QOS value.
+	 * @throw std::invalid_argument If the qos value is invalid.
+	 */
+	static void validate_qos(int qos) throw(std::invalid_argument) {
+		if (qos < 0 || qos > 2)
+			throw std::invalid_argument("QOS invalid");
+	}
+};
+
+typedef message::ptr_t message_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_message_h
+
diff --git a/include/mqtt/token.h b/include/mqtt/token.h
new file mode 100644
index 0000000..b79c9bf
--- /dev/null
+++ b/include/mqtt/token.h
@@ -0,0 +1,331 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file token.h 
+/// Declaration of MQTT token class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_token_h
+#define __mqtt_token_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/iaction_listener.h"
+#include "mqtt/exception.h"
+#include <string>
+#include <vector>
+#include <memory>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
+#include <chrono>
+
+namespace mqtt {
+
+class iasync_client;
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the completion of an asynchronous task. 
+ */
+class itoken
+{
+public:
+	typedef std::shared_ptr<itoken> ptr_t;
+	/**
+	 * Virtual base destructor.
+	 */
+	virtual ~itoken() {}
+	/**
+	 * Return the async listener for this token. 
+	 * @return iaction_listener 
+	 */
+	virtual iaction_listener* get_action_callback() const =0;
+	/**
+	 * Returns the MQTT client that is responsible for processing the 
+	 * asynchronous action.
+	 * @return iasync_client 
+	 */
+	virtual iasync_client* get_client() const =0;
+	/**
+	 * Returns an exception providing more detail if an operation failed.
+	 * @return Exception 
+	 */
+	//virtual exception get_exception() =0;
+	/**
+	 * Returns the message ID of the message that is associated with the 
+	 * token. 
+	 * @return int 
+	 */
+	virtual int get_message_id() const =0;
+	/**
+	 * Returns the topic string(s) for the action being tracked by this 
+	 * token.
+	 * @return std::vector<std::string> 
+	 */
+	virtual const std::vector<std::string>& get_topics() const =0;
+	/**
+	 * Retrieve the context associated with an action.
+	 * @return void* 
+	 */
+	virtual void* get_user_context() const =0;
+	/**
+	 * Returns whether or not the action has finished.
+	 * @return bool 
+	 */
+	virtual bool is_complete() const =0;
+	/**
+	 * Register a listener to be notified when an action completes. 
+	 * @param listener 
+	 */
+	virtual void set_action_callback(iaction_listener& listener) =0;
+	/**
+	 * Store some context associated with an action. 
+	 * @param userContext 
+	 */
+	virtual void set_user_context(void* userContext) =0;
+	/**
+	 * Blocks the current thread until the action this token is associated
+	 * with has completed.
+	 */
+	virtual void wait_for_completion() =0;
+	/**
+	 * Blocks the current thread until the action this token is associated 
+	 * with has completed. 
+	 * @param timeout 
+	 */
+	virtual void wait_for_completion(long timeout) =0;
+};
+
+typedef itoken::ptr_t itoken_ptr;
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Provides a mechanism for tracking the completion of an asynchronous 
+ * action. 
+ */
+class token : public virtual itoken
+{
+	/** Lock guard type for this class. */
+	typedef std::unique_lock<std::mutex> guard;
+
+	/** Object monitor mutex. */
+	mutable std::mutex lock_;
+	/** Condition variable signals when the action completes */
+	mutable std::condition_variable cond_;
+	/** The underlying C token. Note that this is just an integer */
+	MQTTAsync_token tok_;
+	/** The topic string(s) for the action being tracked by this token */
+	std::vector<std::string> topics_;
+	/** The MQTT client that is processing this action */
+	iasync_client* cli_;
+	/** User supplied context */
+	void* userContext_;
+	/**
+	 * User supplied listener.
+	 * Note that the user listener fires after the action is marked 
+	 * complete, but before the token is signaled.
+	 */
+	iaction_listener* listener_;
+	/** Whether the action has yet to complete */
+	bool complete_;
+	/** The action success/failure code */
+	int rc_;
+
+	/** Client has special access for full initialization */
+	friend class async_client;
+
+	void set_topics(const std::string& top) { 
+		topics_.clear();
+		topics_.push_back(top); 
+	}
+	void set_topics(const std::vector<std::string>& top) {
+		topics_ = top;
+	}
+
+	/**
+	 * C-style callback for success. 
+	 * This simply passes the call on to the proper token object for 
+	 * processing. 
+	 * @param tokObj The token object to process the call. Note that this is 
+	 *  			 @em not the user-supplied context pointer. That is
+	 *  			 kept in the object itself.
+	 * @param rsp The success response.
+	 */
+	static void on_success(void* tokObj, MQTTAsync_successData* rsp);
+	/**
+	 * C-style callback for failure. 
+	 * This simply passes the call on to the proper token object for 
+	 * processing. 
+	 * @param tokObj The token object to process the call. Note that this is 
+	 *  			 @em not the user-supplied context pointer. That is
+	 *  			 kept in the object itself.
+	 * @param rsp The failure response.
+	 */
+	static void on_failure(void* tokObj, MQTTAsync_failureData* rsp);
+	/**
+	 * Internal handler for the success callback. 
+	 * @param rsp The success response.
+	 */
+	void on_success(MQTTAsync_successData* rsp);
+	/**
+	 * Internal handler for the failure callback. 
+	 * @param rsp The failure response.
+	 */
+	void on_failure(MQTTAsync_failureData* rsp);
+
+public:
+	typedef std::shared_ptr<token> ptr_t;
+	/**
+	 * Constructs a token object. 
+	 * @param cli 
+	 */
+	token(iasync_client& cli);
+	/**
+	 * Constructs a token object. 
+	 * @param tok 
+	 */
+	token(iasync_client& cli, MQTTAsync_token tok);
+	/**
+	 * Constructs a token object. 
+	 * @param cli 
+	 */
+	token(iasync_client& cli, const std::string& topic);
+	/**
+	 * Constructs a token object. 
+	 * @param cli 
+	 */
+	token(iasync_client& cli, const std::vector<std::string>& topics);
+
+	//token(const std::string& logContext);
+
+	/**
+	 * Return the async listener for this token.
+	 * @return iaction_listener 
+	 */
+	virtual iaction_listener* get_action_callback() const {
+		// TODO: Guard?
+		return listener_;
+	}
+	/**
+	 * Returns the MQTT client that is responsible for processing the 
+	 * asynchronous action. 
+	 * @return iasync_client 
+	 */
+	virtual iasync_client* get_client() const {
+		return (iasync_client*) cli_;
+	}
+	/**
+	 * Returns an exception providing more detail if an operation failed.
+	 * @return Exception 
+	 */
+	//virtual exception get_exception();
+	/**
+	 * Returns the message ID of the message that is associated with the 
+	 * token.
+	 * @return int 
+	 */
+	virtual int get_message_id() const { return int(tok_); }
+	/**
+	 * Returns the topic string(s) for the action being tracked by this 
+	 * token.
+	 */
+	virtual const std::vector<std::string>& get_topics() const {
+		return topics_;
+	}
+	/**
+	 * Retrieve the context associated with an action.
+	 */
+	virtual void* get_user_context() const {
+		guard g(lock_);
+		return userContext_;
+	}
+	/**
+	 * Returns whether or not the action has finished. 
+	 * @return bool 
+	 */
+	virtual bool is_complete() const { return complete_; }
+	/**
+	 * Register a listener to be notified when an action completes.
+	 * @param listener 
+	 */
+	virtual void set_action_callback(iaction_listener& listener) {
+		guard g(lock_);
+		listener_ = &listener;
+	}
+	/**
+	 * Store some context associated with an action.
+	 * @param userContext 
+	 */
+	virtual void set_user_context(void* userContext) {
+		guard g(lock_);
+		userContext_ = userContext;
+	}
+	/**
+	 * Blocks the current thread until the action this token is associated
+	 * with has completed.
+	 */
+	virtual void wait_for_completion();
+	/**
+	 * Blocks the current thread until the action this token is associated 
+	 * with has completed.
+	 * @param timeout The timeout (in milliseconds)
+	 */
+	virtual void wait_for_completion(long timeout);
+	/**
+	 * Waits a relative amount of time for the action to complete.
+	 * @param relTime The amount of time to wait for the event. 
+	 * @return @em true if the event gets signaled in the specified time, 
+	 *  	   @em false on a timeout.
+	 */
+	template <class Rep, class Period>
+	bool wait_for_completion(const std::chrono::duration<Rep, Period>& relTime) {
+		wait_for_completion((long) std::chrono::duration_cast<std::chrono::milliseconds>(relTime).count());
+		return rc_ == 0;
+	}
+	/**
+	 * Waits until an absolute time for the action to complete.
+	 * @param absTime The absolute time to wait for the event. 
+	 * @return @em true if the event gets signaled in the specified time, 
+	 *  	   @em false on a timeout.
+	 */
+	template <class Clock, class Duration>
+	bool wait_until_completion(const std::chrono::time_point<Clock, Duration>& absTime) {
+		guard g(lock_);
+		if (!cond_.wait_until(g, absTime, [this]{return complete_;}))
+			return false;
+		if (rc_ != MQTTASYNC_SUCCESS)
+			throw exception(rc_);
+		return true;
+	}
+
+};
+
+typedef token::ptr_t token_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_token_h
+
diff --git a/include/mqtt/topic.h b/include/mqtt/topic.h
new file mode 100644
index 0000000..3aabd90
--- /dev/null
+++ b/include/mqtt/topic.h
@@ -0,0 +1,115 @@
+/////////////////////////////////////////////////////////////////////////////
+/// @file topic.h 
+/// Declaration of MQTT topic class 
+/// @date May 1, 2013 
+/// @author Frank Pagliughi 
+/////////////////////////////////////////////////////////////////////////////  
+
+/*******************************************************************************
+ * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution. 
+ *
+ * The Eclipse Public License is available at 
+ *    http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at 
+ *   http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ *    Frank Pagliughi - initial implementation and documentation
+ *******************************************************************************/
+
+#ifndef __mqtt_topic_h
+#define __mqtt_topic_h
+
+extern "C" {
+	#include "MQTTAsync.h"
+}
+
+#include "mqtt/delivery_token.h"
+#include "mqtt/message.h"
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace mqtt {
+
+class async_client;
+
+/////////////////////////////////////////////////////////////////////////////  
+
+/**
+ * Represents a topic destination, used for publish/subscribe messaging. 
+ */
+class topic
+{	
+	/// The topic name
+	std::string name_;
+
+	/// The client to which this topic is connected
+	async_client* cli_;
+
+public:
+	/**
+	 * A smart/shared pointer to this class.
+	 */
+	typedef std::shared_ptr<topic> ptr_t;
+	/**
+	 * Construct an MQTT topic destination for messages. 
+	 * @param name 
+	 * @param cli 
+	 */
+	topic(const std::string& name, async_client& cli) : name_(name), cli_(&cli) {}
+	/**
+	 * Returns the name of the queue or topic. 
+	 * @return std::string 
+	 */
+	std::string get_name() const { return name_; }
+	/**
+	 * Publishes a message on the topic.
+	 * @param payload 
+	 * @param n 
+	 * @param qos 
+	 * @param retained 
+	 * 
+	 * @return delivery_token 
+	 */
+	idelivery_token_ptr publish(const void* payload, size_t n, int qos, bool retained);
+	/**
+	 * Publishes a message on the topic.
+	 * @param payload 
+	 * @param qos 
+	 * @param retained 
+	 * 
+	 * @return delivery_token 
+	 */
+	idelivery_token_ptr publish(const std::string& str, int qos, bool retained) {
+		return publish(str.data(), str.length(), qos, retained);
+	}
+	/**
+	 * Publishes the specified message to this topic, but does not wait for 
+	 * delivery of the message to complete. 
+	 * @param message 
+	 * @return delivery_token 
+	 */
+	idelivery_token_ptr publish(message_ptr msg);
+	/**
+	 * Returns a string representation of this topic.
+	 * @return std::string 
+	 */
+	std::string to_str() const { return name_; }
+};
+
+/**
+ * A shared pointer to the topic class.
+ */
+typedef topic::ptr_t topic_ptr;
+
+/////////////////////////////////////////////////////////////////////////////
+// end namespace mqtt
+}
+
+#endif		// __mqtt_topic_h
+
diff --git a/src/iclient_persistence.cpp b/src/iclient_persistence.cpp
index 755c561..13e4569 100644
--- a/src/iclient_persistence.cpp
+++ b/src/iclient_persistence.cpp
@@ -70,8 +70,8 @@ public:
 // C++ persistence object, which is reassigned to the 'handle'. Subsequent
 // calls have the object address as the handle.
 
-int iclient_persistence::persistence_open(void** handle, char* clientID, 
-										  char* serverURI, void* context)
+int iclient_persistence::persistence_open(void** handle, const char* clientID, 
+										const char* serverURI, void* context)
 {
 	try {
 		if (context) {
diff --git a/src/mqtt/async_client.h b/src/mqtt/async_client.h
deleted file mode 100644
index 3d6df96..0000000
--- a/src/mqtt/async_client.h
+++ /dev/null
@@ -1,650 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file async_client.h
-/// Declaration of MQTT async_client class
-/// @date May 1, 2013
-/// @author Frank Pagliughi
-/////////////////////////////////////////////////////////////////////////////
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_async_client_h
-#define __mqtt_async_client_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/token.h"
-#include "mqtt/delivery_token.h"
-#include "mqtt/iclient_persistence.h"
-#include "mqtt/iaction_listener.h"
-#include "mqtt/connect_options.h"
-#include "mqtt/exception.h"
-#include "mqtt/message.h"
-#include "mqtt/callback.h"
-#include <string>
-#include <vector>
-#include <list>
-#include <memory>
-#include <stdexcept>
-
-namespace mqtt {
-
-const uint32_t		VERSION = 0x00010000;
-const std::string	VERSION_STR("mqttpp v. 0.1"),
-					COPYRIGHT("Copyright (c) 2013 Frank Pagliughi");
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * 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:
- *
- * @li connect
- * @li publish
- * @li subscribe
- * @li unsubscribe
- * @li disconnect
- */
-class iasync_client
-{
-	friend class token;
-	virtual void remove_token(itoken* tok) =0;
-
-public:
-	/** Type for a collection of filters */
-	typedef std::vector<std::string> topic_filter_collection;
-	/** Type for a collection of QOS values */
-	typedef std::vector<int> qos_collection;
-
-	/**
-	 * Virtual destructor
-	 */
-	virtual ~iasync_client() {}
-	/**
-	 * Connects to an MQTT server using the default options.
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect() throw(exception, security_exception) =0;
-	/**
-	 * Connects to an MQTT server using the provided connect options. 
-	 * @param options 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(connect_options options) 
-							throw(exception, security_exception) =0;
-	/**
-	 * Connects to an MQTT server using the specified options.
-	 * 
-	 * @param options 
-	 * 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(connect_options options, void* userContext, 
-							   iaction_listener& cb) throw(exception, security_exception) =0;
-	/**
-	 *  
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(void* userContext, iaction_listener& cb)
-							throw(exception, security_exception) =0;
-	/**
-	 * Disconnects from the server. 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect() throw(exception) =0;
-	/**
-	 * Disconnects from the server.
-	 * 
-	 * @param quiesceTimeout 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(long quiesceTimeout) throw(exception) =0;
-	/**
-	 * Disconnects from the server.
-	 * 
-	 * @param quiesceTimeout 
-	 * @param userContext 
-	 * @param callback 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(long quiesceTimeout, void* userContext, iaction_listener& cb)
-						throw(exception) =0;
-	/**
-	 * Disconnects from the server.
-	 * @param userContext 
-	 * @param callback 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(void* userContext, iaction_listener& cb) 
-						throw(exception) =0;
-	/**
-	 * Returns the delivery token for the specified message ID.
-	 * @return idelivery_token
-	 */
-	virtual idelivery_token_ptr get_pending_delivery_token(int msgID) const =0;
-	/**
-	 * Returns the delivery tokens for any outstanding publish operations. 
-	 * @return idelivery_token[]
-	 */
-	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const =0;
-	/**
-	 * Returns the client ID used by this client.
-	 * @return std::string 
-	 */
-	virtual std::string get_client_id() const =0;
-	/**
-	 * Returns the address of the server used by this client.
-	 */
-	virtual std::string get_server_uri() const =0;
-	/**
-	 * Determines if this client is currently connected to the server.
-	 */
-	virtual bool is_connected() const =0;
-	/**
-	 * Publishes a message to a topic on the server
-	 * @param topic 
-	 * @param payload 
-	 * @param qos 
-	 * @param retained 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, const void* payload, 
-										size_t n, int qos, bool retained) 
-									throw(exception) =0;
-	/**
-	 * Publishes a message to a topic on the server 
-	 * @param topic 
-	 * @param payload 
-	 * @param qos 
-	 * @param retained 
-	 * @param userContext 
-	 * @param cb 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, 
-										const void* payload, size_t n,
-										int qos, bool retained, void* userContext, 
-										iaction_listener& cb) throw(exception) =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. 
-	 * 
-	 * @param topic 
-	 * @param message 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg)
-					throw(exception) =0;
-	/**
-	 * Publishes a message to a topic on the server. 
-	 * @param topic 
-	 * @param message 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg, 
-										void* userContext, iaction_listener& cb)
-					throw(exception) =0;
-	/**
-	 * Sets a callback listener to use for events that happen 
-	 * asynchronously. 
-	 * @param callback 
-	 */
-	virtual void set_callback(callback& cb) throw(exception) =0;
-	/**
-	 * Subscribe to multiple topics, each of which may include wildcards. 
-	 * @param topicFilters 
-	 * @param qos 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
-								 const qos_collection& qos) 
-					throw(std::invalid_argument,exception) =0;
-	/**
-	 * Subscribes to multiple topics, each of which may include wildcards. 
-	 * @param topicFilters 
-	 * @param qos 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
-								 const qos_collection& qos,
-								 void* userContext, iaction_listener& callback)
-					throw(std::invalid_argument,exception) =0;
-	/**
-	 * Subscribe to a topic, which may include wildcards. 
-	 * @param topicFilter 
-	 * @param qos 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos) 
-					throw(exception) =0;
-	/**
-	 * Subscribe to a topic, which may include wildcards. 
-	 * @param topicFilter 
-	 * @param qos 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos, 
-								 void* userContext, iaction_listener& callback)
-					throw(exception) =0;
-	/**
-	 * Requests the server unsubscribe the client from a topic. 
-	 * @param topicFilter 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const std::string& topicFilter) throw(exception) =0;
-	/**
-	 * Requests the server unsubscribe the client from one or more topics. 
-	 * @param string 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters) 
-					throw(exception) =0;
-	/**
-	 * Requests the server unsubscribe the client from one or more topics. 
-	 * @param string 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters, 
-								   void* userContext, iaction_listener& callback)
-					throw(exception) =0;
-	/**
-	 * Requests the server unsubscribe the client from a topics. 
-	 * @param topicFilter 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const std::string& topicFilter, 
-								   void* userContext, iaction_listener& callback)
-					throw(exception) =0;
-};
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Lightweight client for talking to an MQTT server using non-blocking
- * methods that allow an operation to run in the background.
- */
-class async_client : public virtual iasync_client
-{
-public:
-	/** Pointer type for this object */
-	typedef std::shared_ptr<async_client> ptr_t;
-
-private:
-	/** Lock guard type for this class */
-	typedef std::unique_lock<std::mutex> guard;
-
-	/** Object monitor mutex */
-	mutable std::mutex lock_;
-	/** The underlying C-lib client. */
-	MQTTAsync cli_;
-	/** The server URI string. */
-	std::string serverURI_;
-	/** The client ID string that we provided to the server. */
-	std::string clientId_;
-	/** A user persistence wrapper (if any) */
-	MQTTClient_persistence* persist_;
-	/** Callback supplied by the user (if any) */
-	callback* userCallback_;
-	/** A list of tokens that are in play */
-	std::list<itoken_ptr> pendingTokens_;
-	/** A list of delivery tokens that are in play */
-	std::list<idelivery_token_ptr> pendingDeliveryTokens_;
-
-	static void on_connection_lost(void *context, char *cause);
-	static int on_message_arrived(void* context, char* topicName, int topicLen, 
-								  MQTTAsync_message* msg);
-	static void on_delivery_complete(void* context, MQTTAsync_token tok);
-
-	/** Manage internal list of active tokens */
-	friend class token;
-	virtual void add_token(itoken_ptr tok);
-	virtual void add_token(idelivery_token_ptr tok);
-	virtual void remove_token(itoken* tok);
-	virtual void remove_token(itoken_ptr tok) { remove_token(tok.get()); }
-	void remove_token(idelivery_token_ptr tok) { remove_token(tok.get()); }
-
-	/** Memory management for C-style filter collections */
-	std::vector<char*> alloc_topic_filters(
-							const topic_filter_collection& topicFilters);
-	void free_topic_filters(std::vector<char*>& filts);
-
-	/**
-	 * Convenience function to get user callback safely. 
-	 * @return callback* 
-	 */
-	callback* get_callback() const {
-		guard g(lock_);
-		return userCallback_;
-	}
-
-	/** Non-copyable */
-	async_client() =delete;
-	async_client(const async_client&) =delete;
-	async_client& operator=(const async_client&) =delete;
-
-public:
-	/**
-	 * Create an async_client that can be used to communicate with an MQTT
-	 * server. 
-	 * This uses file-based persistence in the current working directory.
-	 * @param serverURI 
-	 * @param clientId 
-	 */
-	async_client(const std::string& serverURI, const std::string& clientId);
-	/**
-	 * Create an async_client that can be used to communicate with an MQTT
-	 * server. 
-	 * This uses file-based persistence in the specified directory. 
-	 * @param serverURI 
-	 * @param clientId 
-	 * @param persistDir 
-	 */
-	async_client(const std::string& serverURI, const std::string& clientId,
-				 const std::string& persistDir);
-	/**
-	 * Create an async_client that can be used to communicate with an MQTT
-	 * server. 
-	 * This allows the caller to specify a user-defined persistance object, 
-	 * or use no persistence. 
-	 * @param serverURI 
-	 * @param clientId 
-	 * @param persistence The user persistence structure. If this is null, 
-	 *  				  then no persistence is used.
-	 */
-	async_client(const std::string& serverURI, const std::string& clientId, 
-				 iclient_persistence* persistence);
-	/**
-	 * Destructor
-	 */
-	~async_client();
-	/**
-	 * Connects to an MQTT server using the default options.
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect() throw(exception, security_exception);
-	/**
-	 * Connects to an MQTT server using the provided connect options. 
-	 * @param options 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(connect_options options) throw(exception, security_exception);
-	/**
-	 * Connects to an MQTT server using the specified options.
-	 * 
-	 * @param options 
-	 * 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(connect_options options, void* userContext, 
-							   iaction_listener& cb) throw(exception, security_exception);
-	/**
-	 *  
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 * @throw exception 
-	 * @throw security_exception
-	 */
-	virtual itoken_ptr connect(void* userContext, iaction_listener& cb)
-							throw(exception, security_exception);
-	/**
-	 * Disconnects from the server. 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect() throw(exception) { return disconnect(0L); }
-	/**
-	 * Disconnects from the server.
-	 * 
-	 * @param quiesceTimeout 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(long quiesceTimeout) throw(exception);
-	/**
-	 * Disconnects from the server.
-	 * 
-	 * @param quiesceTimeout 
-	 * @param userContext 
-	 * @param callback 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(long quiesceTimeout, void* userContext, iaction_listener& cb)
-						throw(exception);
-	/**
-	 * Disconnects from the server.
-	 * @param userContext 
-	 * @param callback 
-	 * @return itoken_ptr
-	 */
-	virtual itoken_ptr disconnect(void* userContext, iaction_listener& cb) throw(exception) {
-		return disconnect(0L, userContext, cb);
-	}
-	/**
-	 * Returns the delivery token for the specified message ID.
-	 * @return idelivery_token
-	 */
-	virtual idelivery_token_ptr get_pending_delivery_token(int msgID) const;
-	/**
-	 * Returns the delivery tokens for any outstanding publish operations. 
-	 * @return idelivery_token[]
-	 */
-	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const;
-	/**
-	 * Returns the client ID used by this client.
-	 * @return std::string 
-	 */
-	virtual std::string get_client_id() const { return clientId_; }
-	/**
-	 * Returns the address of the server used by this client.
-	 */
-	virtual std::string get_server_uri() const { return serverURI_; }
-	/**
-	 * Determines if this client is currently connected to the server.
-	 */
-	virtual bool is_connected() const { return MQTTAsync_isConnected(cli_) != 0; }
-	/**
-	 * Publishes a message to a topic on the server
-	 * @param topic 
-	 * @param payload 
-	 * @param qos 
-	 * @param retained 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, const void* payload, 
-										size_t n, int qos, bool retained) throw(exception);
-	/**
-	 * Publishes a message to a topic on the server 
-	 * @param topic 
-	 * @param payload 
-	 * @param qos 
-	 * @param retained 
-	 * @param userContext 
-	 * @param cb 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, 
-										const void* payload, size_t n,
-										int qos, bool retained, void* userContext, 
-										iaction_listener& cb) throw(exception);
-	/**
-	 * 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. 
-	 * 
-	 * @param topic 
-	 * @param message 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg)
-					throw(exception);
-	/**
-	 * Publishes a message to a topic on the server. 
-	 * @param topic 
-	 * @param message 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return idelivery_token 
-	 */
-	virtual idelivery_token_ptr publish(const std::string& topic, message_ptr msg, 
-										void* userContext, iaction_listener& cb)
-					throw(exception);
-	/**
-	 * Sets a callback listener to use for events that happen 
-	 * asynchronously. 
-	 * @param callback 
-	 */
-	virtual void set_callback(callback& cb) throw(exception);
-	/**
-	 * Subscribe to multiple topics, each of which may include wildcards. 
-	 * @param topicFilters 
-	 * @param qos 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
-								 const qos_collection& qos) 
-					throw(std::invalid_argument,exception);
-	/**
-	 * Subscribes to multiple topics, each of which may include wildcards. 
-	 * @param topicFilters 
-	 * @param qos 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const topic_filter_collection& topicFilters, 
-								 const qos_collection& qos,
-								 void* userContext, iaction_listener& callback)
-					throw(std::invalid_argument,exception);
-	/**
-	 * Subscribe to a topic, which may include wildcards. 
-	 * @param topicFilter 
-	 * @param qos 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos) 
-					throw(exception);
-	/**
-	 * Subscribe to a topic, which may include wildcards. 
-	 * @param topicFilter 
-	 * @param qos 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr subscribe(const std::string& topicFilter, int qos, 
-								 void* userContext, iaction_listener& callback)
-					throw(exception);
-	/**
-	 * Requests the server unsubscribe the client from a topic. 
-	 * @param topicFilter 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const std::string& topicFilter) throw(exception);
-	/**
-	 * Requests the server unsubscribe the client from one or more topics. 
-	 * @param string 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters) 
-					throw(exception);
-	/**
-	 * Requests the server unsubscribe the client from one or more topics. 
-	 * @param string 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const topic_filter_collection& topicFilters, 
-								   void* userContext, iaction_listener& callback)
-					throw(exception);
-	/**
-	 * Requests the server unsubscribe the client from a topics. 
-	 * @param topicFilter 
-	 * @param userContext 
-	 * @param callback 
-	 * 
-	 * @return bool 
-	 */
-	virtual itoken_ptr unsubscribe(const std::string& topicFilter, 
-								   void* userContext, iaction_listener& callback)
-					throw(exception);
-};
-
-/**
- * Shared pointer to an asynchronous MQTT client object.
- */
-typedef async_client::ptr_t async_client_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_async_client_h
-
diff --git a/src/mqtt/callback.h b/src/mqtt/callback.h
deleted file mode 100644
index a2e7f0e..0000000
--- a/src/mqtt/callback.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file callback.h
-/// Declaration of MQTT callback class
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_callback_h
-#define __mqtt_callback_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/delivery_token.h"
-#include <string>
-#include <vector>
-#include <memory>
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the completion of an asynchronous 
- * action. 
- */
-class callback
-{
-public:
-	typedef std::shared_ptr<callback> ptr_t;
-	/**
-	 * This method is called when the connection to the server is lost.
-	 * @param cause 
-	 */
-	virtual void connection_lost(const std::string& cause) =0;
-	/**
-	 * This method is called when a message arrives from the server. 
-	 * @param topic
-	 * @param msg 
-	 */
-	virtual void message_arrived(const std::string& topic, message_ptr msg) =0;
-	/**
-	 * Called when delivery for a message has been completed, and all 
-	 * acknowledgments have been received.
-	 * @param token 
-	 */
-	virtual void delivery_complete(idelivery_token_ptr tok) =0;
-};
-
-typedef callback::ptr_t callback_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_callback_h
-
diff --git a/src/mqtt/client.h b/src/mqtt/client.h
deleted file mode 100644
index 41a7b13..0000000
--- a/src/mqtt/client.h
+++ /dev/null
@@ -1,229 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file client.h 
-/// Declaration of MQTT client class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_client_h
-#define __mqtt_client_h
-
-//extern "C" {
-//	#include "MQTTClient.h"
-//	#include "MQTTClientPersistence.h"
-//}
-
-#include "async_client.h"
-
-#include <string>
-#include <memory>
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Lightweight client for talking to an MQTT server using methods that block
- * until an operation completes.
- */
-class client
-{
-	static const int DFLT_QOS;
-
-	//MQTTClient cli_;
-
-	/**
-	 * The actual client
-	 */
-	async_client cli_;
-	/**
-	 * The longest amount of time to wait for an operation (in milliseconds)
-	 */
-	int timeout_;
-
-	/** Non-copyable */
-	client() =delete;
-	client(const async_client&) =delete;
-	client& operator=(const async_client&) =delete;
-
-public:
-	/** Smart pointer type for this object */
-	typedef std::shared_ptr<client> ptr_t;
-	/** Type for a collection of filters */
-	typedef async_client::topic_filter_collection topic_filter_collection;
-	/** Type for a collection of QOS values */
-	typedef async_client::qos_collection qos_collection;
-
-	/**
-	 * Create a client that can be used to communicate with an MQTT server.
-	 * This uses file-based persistence in the current working directory.
-	 * @param serverURI 
-	 * @param clientId 
-	 */
-	client(const std::string& serverURI, const std::string& clientId);
-	/**
-	 * Create a client that can be used to communicate with an MQTT server.
-	 * This uses file-based persistence in the specified directory. 
-	 * @param serverURI 
-	 * @param clientId 
-	 * @param persistDir 
-	 */
-	client(const std::string& serverURI, const std::string& clientId,
-		   const std::string& persistDir);
-	/**
-	 * Create a client that can be used to communicate with an MQTT server.
-	 * This allows the caller to specify a user-defined persistance object, 
-	 * or use no persistence. 
-	 * @param serverURI 
-	 * @param clientId 
-	 * @param persistence The user persistence structure. If this is null, 
-	 *  				  then no persistence is used.
-	 */
-	client(const std::string& serverURI, const std::string& clientId, 
-		   iclient_persistence* persistence);
-	/**
-	 * Close the client and releases all resource associated with the 
-	 * client. 
-	 */
-	virtual void close();
-	/**
-	 * Connects to an MQTT server using the default options.
-	 */
-	virtual void connect();
-	/**
-	 * Connects to an MQTT server using the specified options.
-	 * @param options 
-	 */
-	virtual void connect(connect_options options);
-	/**
-	 * Disconnects from the server.
-	 */
-	virtual void disconnect();
-	/**
-	 * Disconnects from the server.
-	 */
-	virtual void disconnect(long quiesceTimeout);
-	/**
-	 * Returns a randomly generated client identifier based on the current 
-	 * user's login name and the system time. 
-	 */
-	//static std::string generateClientId();
-	/**
-	 * Returns the client ID used by this client.
-	 * @return std::string 
-	 */
-	virtual std::string get_client_id() const;
-
-	//Debug 	getDebug()
-	//Return a debug object that can be used to help solve problems.
-
-	/**
-	 * Returns the delivery tokens for any outstanding publish operations.
-	 */
-	virtual std::vector<idelivery_token_ptr> get_pending_delivery_tokens() const;
-	/**
-	 * Returns the address of the server used by this client, as a URI.
-	 * @return std::string 
-	 */
-	virtual std::string get_server_uri() const;
-	/**
-	 * Return the maximum time to wait for an action to complete. 
-	 * @return long 
-	 */
-	virtual long get_time_to_wait() const;
-	/**
-	 * Get a topic object which can be used to publish messages.
-	 * @param tpc 
-	 * @return topic 
-	 */
-	virtual topic get_topic(const std::string& tpc);
-	/**
-	 * Determines if this client is currently connected to the server. 
-	 * @return bool 
-	 */
-	virtual bool is_connected() const;
-	/**
-	 * Publishes a message to a topic on the server and return once it is 
-	 * delivered. 
-	 * @param topic 
-	 * @param payload 
-	 * @param n 
-	 * @param qos 
-	 * @param retained 
-	 */
-	virtual void publish(const std::string& top, const void* payload, size_t n,
-						 int qos, bool retained);
-	/**
-	 * Publishes a message to a topic on the server. 
-	 * @param tpc 
-	 * @param msg 
-	 */
-	virtual void publish(const std::string& tpc, message_ptr msg);
-	/**
-	 * Sets the callback listener to use for events that happen 
-	 * asynchronously.
-	 * @param callback 
-	 */
-	virtual void set_callback(callback& cb);
-	/**
-	 * Set the maximum time to wait for an action to complete 
-	 * @param timeToWaitInMillis 
-	 */
-	virtual void set_time_to_wait(int timeToWaitInMillis);
-	/**
-	 * Subscribe to a topic, which may include wildcards using a QoS of 1. 
-	 * @param topicFilter 
-	 */
-	virtual void subscribe(const std::string& topicFilter);
-	/**
-	 * Subscribes to a one or more topics, which may include wildcards using
-	 * a QoS of 1.
-	 */
-	virtual void subscribe(const topic_filter_collection& topicFilters);
-	/**
-	 * Subscribes to multiple topics, each of which may include wildcards.
-	 * @param string 
-	 */
-	virtual void subscribe(const topic_filter_collection& topicFilters, 
-						   const qos_collection& qos);
-	/**
-	 * Subscribe to a topic, which may include wildcards.
-	 * @param topicFilter 
-	 * @param qos 
-	 */
-	virtual void subscribe(const std::string& topicFilter, int qos);
-	/**
-	 * Requests the server unsubscribe the client from a topic. 
-	 * @param topicFilter 
-	 */
-	virtual void unsubscribe(const std::string& topicFilter);
-	/**
-	 * Requests the server unsubscribe the client from one or more topics.
-	 */
-	virtual void unsubscribe(const topic_filter_collection& topicFilters);
-};
-
-typedef client::ptr_t client_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_client_h
-
diff --git a/src/mqtt/connect_options.h b/src/mqtt/connect_options.h
deleted file mode 100644
index ed19885..0000000
--- a/src/mqtt/connect_options.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file connect_options.h 
-/// Declaration of MQTT connect_options class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_connect_options_h
-#define __mqtt_connect_options_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/message.h"
-#include "mqtt/topic.h"
-#include <string>
-#include <vector>
-#include <memory>
-
-namespace mqtt {
-
-class async_client;
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Holds the set of options that control how the client connects to a 
- * server. 
- */
-class connect_options
-{
-	/** The underlying C connection options */
-	MQTTAsync_connectOptions opts_;
-
-	/** The client has special access */
-	friend class async_client;
-
-public:
-	/**
-	 * Smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<connect_options> ptr_t;
-	/**
-	 * Constructs a new MqttConnectOptions object using the default values.
-	 */
-	connect_options() : opts_( MQTTAsync_connectOptions_initializer ) {}
-	/**
-	 * Returns the connection timeout value. 
-	 * @return int 
-	 */
-	int get_connection_timeout() const;
-
-	//java.util.Properties getDebug()
-           
-	/**
-	 * Returns the "keep alive" interval.
-	 * @return int 
-	 */
-	int get_keep_alive_interval() const {
-		return opts_.keepAliveInterval;
-	}
-	/**
-	 * Returns the password to use for the connection.
-	 * @return std::string 
-	 */
-	std::string get_password() const {
-		return std::string(opts_.password);
-	}
-	/**
-	 * Returns the socket factory that will be used when connecting, or null 
-	 * if one has not been set.
-	 */
-	//javax.net.SocketFactory get_socket_factory();
-	/**
-	 * Returns the SSL properties for the connection.
-	 */
-	//java.util.Properties get_ssl_properties();
-	/**
-	 * Returns the user name to use for the connection.
-	 * @return std::string 
-	 */
-	std::string get_user_name() const { 
-		return std::string(opts_.username);
-	}
-	/**
-	 * Returns the topic to be used for last will and testament (LWT).
-	 * @return std::string 
-	 */
-	std::string get_will_destination() const;
-	/**
-	 * Returns the message to be sent as last will and testament (LWT).
-	 * @return MqttMessage 
-	 */
-	message get_will_message() const;
-	/**
-	 * Returns whether the server should remember state for the client 
-	 * across reconnects.
-	 * @return bool 
-	 */
-	bool is_clean_session() const { return opts_.cleansession != 0; }
-	/**
-	 * Sets whether the server should remember state for the client across 
-	 * reconnects. 
-	 * @param cleanSession 
-	 */
-	void set_clean_session(bool cleanSession) {
-		opts_.cleansession = (cleanSession) ? (!0) : 0;
-	}
-	/**
-	 * Sets the connection timeout value.
-	 * @param timeout 
-	 */
-	void set_connection_timeout(int timeout) {
-		opts_.connectTimeout = timeout;
-	}
-	/**
-	 * Sets the "keep alive" interval. 
-	 * @param keepAliveInterval 
-	 */
-	void set_keep_alive_interval(int keepAliveInterval) {
-		opts_.keepAliveInterval = keepAliveInterval;
-	}
-	/**
-	 * Sets the password to use for the connection.
-	 */
-	void set_password(const std::string& password);
-	/**
-	 * Sets the SocketFactory to use.
-	 */
-	//void set_socket_factory(javax.net.SocketFactory socketFactory)
-	/**
-	 * Sets the SSL properties for the connection.
-	 */
-	//void set_ssl_properties(java.util.Properties props);
-	/**
-	 * Sets the user name to use for the connection.
-	 * @param userName 
-	 */
-	void set_user_name(const std::string& userName);
-	/**
-	 * Sets the "Last Will and Testament" (LWT) for the connection.
-	 * @param top 
-	 * @param payload 
-	 * @param n 
-	 * @param qos 
-	 * @param retained 
-	 */
-	void set_will(const topic& top, void* payload, size_t n, int qos, bool retained) {
-		set_will(top.get_name(), payload, n, qos, retained);
-	}
-	/**
-	 * Sets the "Last Will and Testament" (LWT) for the connection.
-	 * @param top 
-	 * @param payload 
-	 * @param n 
-	 * @param qos 
-	 * @param retained 
-	 */
-	void set_will(const std::string& top, void* payload, size_t n, int qos, bool retained);
-	/**
-	 * Sets up the will information, based on the supplied parameters. 
-	 * @param top 
-	 * @param msg 
-	 * @param qos 
-	 * @param retained 
-	 */
-	/*protected*/ void set_will(const std::string& top, message msg, int qos, bool retained);
-
-	std::string to_str() const;
-};
-
-/**
- * Shared pointer to the connection options class.
- */
-typedef connect_options::ptr_t connect_options_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_connect_options_h
-
diff --git a/src/mqtt/delivery_token.h b/src/mqtt/delivery_token.h
deleted file mode 100644
index fc52249..0000000
--- a/src/mqtt/delivery_token.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file delivery_token.h 
-/// Declaration of MQTT delivery_token class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_delivery_token_h
-#define __mqtt_delivery_token_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/token.h"
-#include "mqtt/message.h"
-#include <memory>
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the delivery of a message.
- */
-class idelivery_token : public virtual itoken
-{
-public:
-	typedef std::shared_ptr<idelivery_token> ptr_t;
-	/**
-	 * Returns the message associated with this token. 
-	 * @return The message associated with this token.
-	 */
-	virtual message_ptr get_message() const =0;          
-};
-
-typedef idelivery_token::ptr_t idelivery_token_ptr;
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism to track the delivery progress of a message.
- * Used to track the the delivery progress of a message when a publish is
- * executed in a non-blocking manner (run in the background) action.
- */
-class delivery_token : public virtual idelivery_token,
-						public token
-{
-	/** The message being tracked. */
-	message_ptr msg_;
-
-	/** Client has special access. */
-	friend class async_client;
-
-	/**
-	 * Sets the message that this token correspn
-	 * @param msg 
-	 */
-	void set_message(message_ptr msg) { msg_ = msg; }
-
-public:
-	/**
-	 * Smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<delivery_token> ptr_t;
-
-	delivery_token(iasync_client& cli) : token(cli) {}
-
-	delivery_token(iasync_client& cli, const std::string& topic) : token(cli, topic) {}
-
-	delivery_token(iasync_client& cli, const std::vector<std::string>& topics) 
-					: token(cli, topics) {}
-
-	//delivery_token(const std::string& logContext);
-
-	/**
-	 * Returns the message associated with this token.
-	 * @return message 
-	 */
-	virtual message_ptr get_message() const { return msg_; }
-};
-
-/**
- * Shared pointer to a delivery_token.
- */
-typedef delivery_token::ptr_t delivery_token_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_delivery_token_h
-
diff --git a/src/mqtt/exception.h b/src/mqtt/exception.h
deleted file mode 100644
index 301c8b8..0000000
--- a/src/mqtt/exception.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file exception.h 
-/// Declaration of MQTT exception class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_exception_h
-#define __mqtt_exception_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include <string>
-#include <vector>
-#include <memory>
-#include <exception>
-#include <stdexcept>
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the completion of an asynchronous 
- * action. 
- */
-class exception : public std::runtime_error
-{
-	int code_;
-
-public:
-	explicit exception(int reasonCode) : std::runtime_error("mqtt::exception"),
-											code_(reasonCode) {}
-	/**
-	 * Returns the underlying cause of this exception, if available.
-	 */
-	//java.lang.Throwable 	getCause()
-	/**
-	 * Returns the detail message for this exception.
-	 */
-	std::string get_message()  const { return std::string(what()); }
-	/**
-	 * Returns the reason code for this exception.
-	 */
-	int get_reason_code() const { return code_; }
-	/**
-	 * Returns a String representation of this exception. 
-	 * @return std::tring 
-	 */
-	std::string to_str() const { return std::string(what()); }
-	/**
-	 * Returns an explanatory string for the exception.
-	 * @return const char* 
-	 */
-	virtual const char* what() const noexcept {
-		return std::exception::what();
-	}
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * This exception is thrown by the implementor of the persistence interface
- * if there is a problem reading or writing persistent data.
- */
-class persistence_exception : public exception
-{
-public:
-	// TODO: Define "reason codes"
-	persistence_exception() : exception(MQTTCLIENT_PERSISTENCE_ERROR) {}
-	persistence_exception(int reasonCode) : exception(reasonCode) {}
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Thrown when a client is not authorized to perform an operation, or if
-   there is a problem with the security configuration.
- */
-class security_exception : public exception
-{
-public:
-	security_exception(int reasonCode) : exception(reasonCode) {}
-};
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_token_h
-
diff --git a/src/mqtt/iaction_listener.h b/src/mqtt/iaction_listener.h
deleted file mode 100644
index e54cf1c..0000000
--- a/src/mqtt/iaction_listener.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file iaction_listener.h 
-/// Declaration of MQTT iaction_listener class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_iaction_listener_h
-#define __mqtt_iaction_listener_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include <string>
-#include <vector>
-#include <memory>
-
-namespace mqtt {
-	
-class itoken;
- 	
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the completion of an asynchronous 
- * action. 
- *  
- * A listener is registered on a token and that token is associated with
- * an action like connect or publish. When used with tokens on the
- * async_client the listener will be called back on the MQTT client's
- * thread. The listener will be informed if the action succeeds or fails. It
- * is important that the listener returns control quickly otherwise the
- * operation of the MQTT client will be stalled.
- */
-class iaction_listener
-{
-public:
-	/**
-	 * Shared pointer to this class.
-	 */
-	typedef std::shared_ptr<iaction_listener> ptr_t;
-	/**
-	 * Virtual base destructor.
-	 */
-	virtual ~iaction_listener() {}
-	/**
-	 * This method is invoked when an action fails. 
-	 * @param asyncActionToken 
-	 * @param exc 
-	 */
-	virtual void on_failure(const itoken& asyncActionToken /*, java.lang.Throwable exc*/) =0;
-	/**
-	 * This method is invoked when an action has completed successfully. 
-	 * @param asyncActionToken 
-	 */
-	virtual void on_success(const itoken& asyncActionToken) =0;
-};
-
-typedef iaction_listener::ptr_t iaction_listener_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_iaction_listener_h
-
diff --git a/src/mqtt/iclient_persistence.h b/src/mqtt/iclient_persistence.h
deleted file mode 100644
index 1fad4df..0000000
--- a/src/mqtt/iclient_persistence.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file iclient_persistence.h 
-/// Declaration of MQTT iclient_persistence interface
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_iclient_persistence_h
-#define __mqtt_iclient_persistence_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/ipersistable.h"
-#include <string>
-#include <memory>
-#include <vector> 
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * Represents a persistent data store, used to store outbound and inbound
- * messages while they are in flight, enabling delivery to the QoS
- * specified. You can specify an implementation of this interface using
- * client::client(string, string, iclient_persistence), which the
- * client will use to persist QoS 1 and 2 messages.
- *
- * If the methods defined throw the MqttPersistenceException then the state
- * of the data persisted should remain as prior to the method being called.
- * For example, if put(string, persistable) throws an exception at any
- * point then the data will be assumed to not be in the persistent store.
- * Similarly if remove(string) throws an exception then the data will be
- * assumed to still be held in the persistent store.
- *
- * It is up to the persistence interface to log any exceptions or error
- * information which may be required when diagnosing a persistence failure.
- */
-class iclient_persistence
-{
-	friend class iasync_client;
-
-public:
-
-	/** C-callbacks  */
-	static int persistence_open(void** handle, char* clientID, char* serverURI, void* context);
-	static int persistence_close(void* handle); 
-	static int persistence_put(void* handle, char* key, int bufcount, char* buffers[], int buflens[]);
-	static int persistence_get(void* handle, char* key, char** buffer, int* buflen);
-	static int persistence_remove(void* handle, char* key);
-	static int persistence_keys(void* handle, char*** keys, int* nkeys);
-	static int persistence_clear(void* handle);
-	static int persistence_containskey(void* handle, char* key);
-
-public:
-	/**
-	 * Smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<iclient_persistence> ptr_t;
-	/**
-	 * Virtual destructor.
-	 */
-	virtual ~iclient_persistence() {}
-	/** 
-	 * Initialise the persistent store.
-	 */          
-	virtual void open(const std::string& clientId, const std::string& serverURI) =0;
-	/**
-	 * Close the persistent store that was previously opened.
-	 */
-	virtual void close() =0;
-	/**
-	 * Clears persistence, so that it no longer contains any persisted data.
-	 */
-	virtual void clear() =0;
-	/**
-	 * Returns whether or not data is persisted using the specified key. 
-	 * @param key 
-	 * @return bool 
-	 */
-	virtual bool contains_key(const std::string& key) =0;
-	/**
-	 * Gets the specified data out of the persistent store.
-	 * @param key 
-	 * @return persistable 
-	 */
-	virtual ipersistable_ptr get(const std::string& key) const =0;
-	/**
-	 * Returns an Enumeration over the keys in this persistent data store.
-	 */
-	virtual std::vector<std::string> keys() const =0;
-	/**
-	 * Puts the specified data into the persistent store.
-	 * @param key 
-	 * @param persistable 
-	 */
-	virtual void put(const std::string& key, ipersistable_ptr persistable) =0;
-	/**
-	 * Remove the data for the specified key. 
-	 * @param key 
-	 */
-	virtual void remove(const std::string& key) =0;
-};
-
-/**
- * Shared pointer to a persistence client.
- */
-typedef std::shared_ptr<iclient_persistence> iclient_persistence_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_iclient_persistence_h
-
diff --git a/src/mqtt/ipersistable.h b/src/mqtt/ipersistable.h
deleted file mode 100644
index 51d7624..0000000
--- a/src/mqtt/ipersistable.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file ipersistable.h 
-/// Declaration of MQTT ipersistable interface.
-/// @date May 24, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_ipersistable_h
-#define __mqtt_ipersistable_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include <string>
-#include <memory>
-#include <vector>
-#include <stdexcept> 
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Represents an object used to pass data to be persisted across the
- * MqttClientPersistence interface.
- *
- * When data is passed across the interface the header and payload are
- * separated, so that unnecessary message copies may be avoided. For
- * example, if a 10 MB payload was published it would be inefficient to
- * create a byte array a few bytes larger than 10 MB and copy the MQTT
- * message header and payload into a contiguous byte array.
- *
- * When the request to persist data is made a separate byte array and offset
- * is passed for the header and payload. Only the data between offset and
- * length need be persisted. So for example, a message to be persisted
- * consists of a header byte array starting at offset 1 and length 4, plus a
- * payload byte array starting at offset 30 and length 40000. There are
- * three ways in which the persistence implementation may return data to the
- * client on recovery:
- *
- * @li
- * It could return the data as it was passed in originally, with the same
- * byte arrays and offsets.
- *
- * @li
- * It could safely just persist and return the bytes from the offset for the
- * specified length. For example, return a header byte array with offset 0
- * and length 4, plus a payload byte array with offset 0 and length 40000
- *
- * @li
- * It could return the header and payload as a contiguous byte array with
- * the header bytes preceeding the payload. The contiguous byte array should
- * be set as the header byte array, with the payload byte array being null.
- * For example, return a single byte array with offset 0 and length 40004.
- * This is useful when recovering from a file where the header and payload
- * could be written as a contiguous stream of bytes.
- */
-
-class ipersistable
-{
-public:
-	/**
-	 * Smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<ipersistable> ptr_t;
-	/**
-	 * Virtual destructor
-	 */
-	virtual ~ipersistable() {}
-	/**
-	 * Returns the header bytes in an array. 
-	 * @return std::vector<uint8_t> 
-	 */
-	virtual const uint8_t* get_header_bytes() const =0;
-	/**
-	 * Returns the header bytes in an array. 
-	 * @return std::vector<uint8_t> 
-	 */
-	virtual std::vector<uint8_t> get_header_byte_arr() const =0;
-	/**
-	 * Returns the length of the header. 
-	 * @return int 
-	 */
-	virtual size_t get_header_length() const =0;
-	/**
-	 * Returns the offset of the header within the byte array returned by 
-	 * get_header_bytes(). 
-	 * @return int 
-	 */
-	virtual size_t get_header_offset() const =0;
-	/**
-	 * Returns the payload bytes in an array.
-	 * @return std::vector<uint8_t> 
-	 */
-	virtual const uint8_t* get_payload_bytes() const =0;
-	/**
-	 * Returns the payload bytes in an array.
-	 * @return std::vector<uint8_t> 
-	 */
-	virtual std::vector<uint8_t> get_payload_byte_arr() const =0;
-	/**
-	 * Returns the length of the payload.
-	 * @return int 
-	 */
-	virtual size_t get_payload_length() const =0;
-	/**
-	 * Returns the offset of the payload within the byte array returned by 
-	 * get_payload_bytes(). 
-	 * 
-	 * @return int 
-	 */
-	virtual size_t get_payload_offset() const =0;
-};
-
-typedef ipersistable::ptr_t ipersistable_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_ipersistable_h
-
-
diff --git a/src/mqtt/message.h b/src/mqtt/message.h
deleted file mode 100644
index 7653619..0000000
--- a/src/mqtt/message.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file message.h 
-/// Declaration of MQTT message class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_message_h
-#define __mqtt_message_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include <string>
-#include <memory>
-#include <stdexcept> 
-
-namespace mqtt {
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * An MQTT message holds the application payload and options specifying how 
- * the message is to be delivered The message includes a "payload" (the body 
- * of the message) represented as a byte array. 
- */
-class message
-{
-	/** The underlying C message struct */
-	MQTTAsync_message msg_;
-
-	/** The client has special access. */
-	friend class async_client;
-
-	/**
-	 * Set the dup flag in the underlying message 
-	 * @param dup 
-	 */
-	void set_duplicate(bool dup) { msg_.dup = (dup) ? (!0) : 0; }
-	/**
-	 * Copies the specified payload into this object.
-	 * @param payload 
-	 * @param len 
-	 */
-	void copy_payload(const void* payload, size_t len);
-
-public:
-	/**
-	 * Smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<message> ptr_t;
-	/**
-	 * Constructs a message with an empty payload, and all other values set
-	 * to defaults.
-	 */
-	message();
-	/**
-	 * Constructs a message with the specified array as a payload, and all 
-	 * other values set to defaults. 
-	 */
-	message(const void* payload, size_t len);
-	/**
-	 * Constructs a message with the specified string as a payload, and 
-	 * all other values set to defaults.
-	 */
-	message(const std::string& payload);
-	/**
-	 * Constructs a message as a copy of the message structure.
-	 */
-	message(const MQTTAsync_message& msg);
-	/**
-	 * Constructs a message as a copy of the other message.
-	 */
-	message(const message& other);
-	/**
-	 * Moves the other message to this one.
-	 */
-	message(message&& other);
-	/**
-	 * Destroys a message and frees all associated resources.
-	 */
-	~message();
-	/**
-	 * Copies another message to this one. 
-	 * @param rhs The other message. 
-	 * @return A reference to this message.
-	 */
-	message& operator=(const message& rhs);
-	/**
-	 * Moves another message to this one. 
-	 * @param rhs The other message. 
-	 * @return A reference to this message.
-	 */
-	message& operator=(message&& rhs);
-	/**
-	 * Clears the payload, resetting it to be empty.
-	 */
-	void clear_payload();
-	/**
-	 * Gets the payload
-	 */
-	std::string get_payload() const;
-	/**
-	 * Returns the quality of service for this message.
-	 * @return The quality of service for this message.
-	 */
-	int get_qos() const { return msg_.qos; }
-	/**
-	 * Returns whether or not this message might be a duplicate of one which 
-	 * has already been received. 
-	 * @return bool 
-	 */
-	bool is_duplicate() const { return msg_.dup != 0; }
-	/**
-	 * Returns whether or not this message should be/was retained by the 
-	 * server.
-	 * @return bool 
-	 */
-	bool is_retained() const { return msg_.retained != 0; }
-	/**
-	 * Sets the payload of this message to be the specified byte array.
-	 */
-	void set_payload(const void* payload, size_t n);
-	/**
-	 * Sets the payload of this message to be the specified string.
-	 */
-	void set_payload(const std::string& payload);
-	/**
-	 * Sets the quality of service for this message.
-	 * 
-	 * @param qos 
-	 */
-	void set_qos(int qos) throw(std::invalid_argument) {
-		validate_qos(qos); 
-		msg_.qos = qos;
-	}
-	/**
-	 * Whether or not the publish message should be retained by the 
-	 * messaging engine. 
-	 * @param retained 
-	 */
-	void set_retained(bool retained) { msg_.retained = (retained) ? (!0) : 0; }
-	/**
-	 * Returns a string representation of this messages payload. 
-	 * @return std::string 
-	 */
-	std::string to_str() const { return get_payload(); }
-	/**
-	 * Determines if the QOS value is a valid one.
-	 * @param qos The QOS value.
-	 * @throw std::invalid_argument If the qos value is invalid.
-	 */
-	static void validate_qos(int qos) throw(std::invalid_argument) {
-		if (qos < 0 || qos > 2)
-			throw std::invalid_argument("QOS invalid");
-	}
-};
-
-typedef message::ptr_t message_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_message_h
-
diff --git a/src/mqtt/token.h b/src/mqtt/token.h
deleted file mode 100644
index b79c9bf..0000000
--- a/src/mqtt/token.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file token.h 
-/// Declaration of MQTT token class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_token_h
-#define __mqtt_token_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/iaction_listener.h"
-#include "mqtt/exception.h"
-#include <string>
-#include <vector>
-#include <memory>
-#include <thread>
-#include <mutex>
-#include <condition_variable>
-#include <chrono>
-
-namespace mqtt {
-
-class iasync_client;
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the completion of an asynchronous task. 
- */
-class itoken
-{
-public:
-	typedef std::shared_ptr<itoken> ptr_t;
-	/**
-	 * Virtual base destructor.
-	 */
-	virtual ~itoken() {}
-	/**
-	 * Return the async listener for this token. 
-	 * @return iaction_listener 
-	 */
-	virtual iaction_listener* get_action_callback() const =0;
-	/**
-	 * Returns the MQTT client that is responsible for processing the 
-	 * asynchronous action.
-	 * @return iasync_client 
-	 */
-	virtual iasync_client* get_client() const =0;
-	/**
-	 * Returns an exception providing more detail if an operation failed.
-	 * @return Exception 
-	 */
-	//virtual exception get_exception() =0;
-	/**
-	 * Returns the message ID of the message that is associated with the 
-	 * token. 
-	 * @return int 
-	 */
-	virtual int get_message_id() const =0;
-	/**
-	 * Returns the topic string(s) for the action being tracked by this 
-	 * token.
-	 * @return std::vector<std::string> 
-	 */
-	virtual const std::vector<std::string>& get_topics() const =0;
-	/**
-	 * Retrieve the context associated with an action.
-	 * @return void* 
-	 */
-	virtual void* get_user_context() const =0;
-	/**
-	 * Returns whether or not the action has finished.
-	 * @return bool 
-	 */
-	virtual bool is_complete() const =0;
-	/**
-	 * Register a listener to be notified when an action completes. 
-	 * @param listener 
-	 */
-	virtual void set_action_callback(iaction_listener& listener) =0;
-	/**
-	 * Store some context associated with an action. 
-	 * @param userContext 
-	 */
-	virtual void set_user_context(void* userContext) =0;
-	/**
-	 * Blocks the current thread until the action this token is associated
-	 * with has completed.
-	 */
-	virtual void wait_for_completion() =0;
-	/**
-	 * Blocks the current thread until the action this token is associated 
-	 * with has completed. 
-	 * @param timeout 
-	 */
-	virtual void wait_for_completion(long timeout) =0;
-};
-
-typedef itoken::ptr_t itoken_ptr;
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Provides a mechanism for tracking the completion of an asynchronous 
- * action. 
- */
-class token : public virtual itoken
-{
-	/** Lock guard type for this class. */
-	typedef std::unique_lock<std::mutex> guard;
-
-	/** Object monitor mutex. */
-	mutable std::mutex lock_;
-	/** Condition variable signals when the action completes */
-	mutable std::condition_variable cond_;
-	/** The underlying C token. Note that this is just an integer */
-	MQTTAsync_token tok_;
-	/** The topic string(s) for the action being tracked by this token */
-	std::vector<std::string> topics_;
-	/** The MQTT client that is processing this action */
-	iasync_client* cli_;
-	/** User supplied context */
-	void* userContext_;
-	/**
-	 * User supplied listener.
-	 * Note that the user listener fires after the action is marked 
-	 * complete, but before the token is signaled.
-	 */
-	iaction_listener* listener_;
-	/** Whether the action has yet to complete */
-	bool complete_;
-	/** The action success/failure code */
-	int rc_;
-
-	/** Client has special access for full initialization */
-	friend class async_client;
-
-	void set_topics(const std::string& top) { 
-		topics_.clear();
-		topics_.push_back(top); 
-	}
-	void set_topics(const std::vector<std::string>& top) {
-		topics_ = top;
-	}
-
-	/**
-	 * C-style callback for success. 
-	 * This simply passes the call on to the proper token object for 
-	 * processing. 
-	 * @param tokObj The token object to process the call. Note that this is 
-	 *  			 @em not the user-supplied context pointer. That is
-	 *  			 kept in the object itself.
-	 * @param rsp The success response.
-	 */
-	static void on_success(void* tokObj, MQTTAsync_successData* rsp);
-	/**
-	 * C-style callback for failure. 
-	 * This simply passes the call on to the proper token object for 
-	 * processing. 
-	 * @param tokObj The token object to process the call. Note that this is 
-	 *  			 @em not the user-supplied context pointer. That is
-	 *  			 kept in the object itself.
-	 * @param rsp The failure response.
-	 */
-	static void on_failure(void* tokObj, MQTTAsync_failureData* rsp);
-	/**
-	 * Internal handler for the success callback. 
-	 * @param rsp The success response.
-	 */
-	void on_success(MQTTAsync_successData* rsp);
-	/**
-	 * Internal handler for the failure callback. 
-	 * @param rsp The failure response.
-	 */
-	void on_failure(MQTTAsync_failureData* rsp);
-
-public:
-	typedef std::shared_ptr<token> ptr_t;
-	/**
-	 * Constructs a token object. 
-	 * @param cli 
-	 */
-	token(iasync_client& cli);
-	/**
-	 * Constructs a token object. 
-	 * @param tok 
-	 */
-	token(iasync_client& cli, MQTTAsync_token tok);
-	/**
-	 * Constructs a token object. 
-	 * @param cli 
-	 */
-	token(iasync_client& cli, const std::string& topic);
-	/**
-	 * Constructs a token object. 
-	 * @param cli 
-	 */
-	token(iasync_client& cli, const std::vector<std::string>& topics);
-
-	//token(const std::string& logContext);
-
-	/**
-	 * Return the async listener for this token.
-	 * @return iaction_listener 
-	 */
-	virtual iaction_listener* get_action_callback() const {
-		// TODO: Guard?
-		return listener_;
-	}
-	/**
-	 * Returns the MQTT client that is responsible for processing the 
-	 * asynchronous action. 
-	 * @return iasync_client 
-	 */
-	virtual iasync_client* get_client() const {
-		return (iasync_client*) cli_;
-	}
-	/**
-	 * Returns an exception providing more detail if an operation failed.
-	 * @return Exception 
-	 */
-	//virtual exception get_exception();
-	/**
-	 * Returns the message ID of the message that is associated with the 
-	 * token.
-	 * @return int 
-	 */
-	virtual int get_message_id() const { return int(tok_); }
-	/**
-	 * Returns the topic string(s) for the action being tracked by this 
-	 * token.
-	 */
-	virtual const std::vector<std::string>& get_topics() const {
-		return topics_;
-	}
-	/**
-	 * Retrieve the context associated with an action.
-	 */
-	virtual void* get_user_context() const {
-		guard g(lock_);
-		return userContext_;
-	}
-	/**
-	 * Returns whether or not the action has finished. 
-	 * @return bool 
-	 */
-	virtual bool is_complete() const { return complete_; }
-	/**
-	 * Register a listener to be notified when an action completes.
-	 * @param listener 
-	 */
-	virtual void set_action_callback(iaction_listener& listener) {
-		guard g(lock_);
-		listener_ = &listener;
-	}
-	/**
-	 * Store some context associated with an action.
-	 * @param userContext 
-	 */
-	virtual void set_user_context(void* userContext) {
-		guard g(lock_);
-		userContext_ = userContext;
-	}
-	/**
-	 * Blocks the current thread until the action this token is associated
-	 * with has completed.
-	 */
-	virtual void wait_for_completion();
-	/**
-	 * Blocks the current thread until the action this token is associated 
-	 * with has completed.
-	 * @param timeout The timeout (in milliseconds)
-	 */
-	virtual void wait_for_completion(long timeout);
-	/**
-	 * Waits a relative amount of time for the action to complete.
-	 * @param relTime The amount of time to wait for the event. 
-	 * @return @em true if the event gets signaled in the specified time, 
-	 *  	   @em false on a timeout.
-	 */
-	template <class Rep, class Period>
-	bool wait_for_completion(const std::chrono::duration<Rep, Period>& relTime) {
-		wait_for_completion((long) std::chrono::duration_cast<std::chrono::milliseconds>(relTime).count());
-		return rc_ == 0;
-	}
-	/**
-	 * Waits until an absolute time for the action to complete.
-	 * @param absTime The absolute time to wait for the event. 
-	 * @return @em true if the event gets signaled in the specified time, 
-	 *  	   @em false on a timeout.
-	 */
-	template <class Clock, class Duration>
-	bool wait_until_completion(const std::chrono::time_point<Clock, Duration>& absTime) {
-		guard g(lock_);
-		if (!cond_.wait_until(g, absTime, [this]{return complete_;}))
-			return false;
-		if (rc_ != MQTTASYNC_SUCCESS)
-			throw exception(rc_);
-		return true;
-	}
-
-};
-
-typedef token::ptr_t token_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_token_h
-
diff --git a/src/mqtt/topic.h b/src/mqtt/topic.h
deleted file mode 100644
index 3aabd90..0000000
--- a/src/mqtt/topic.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-/// @file topic.h 
-/// Declaration of MQTT topic class 
-/// @date May 1, 2013 
-/// @author Frank Pagliughi 
-/////////////////////////////////////////////////////////////////////////////  
-
-/*******************************************************************************
- * Copyright (c) 2013 Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx>
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * and Eclipse Distribution License v1.0 which accompany this distribution. 
- *
- * The Eclipse Public License is available at 
- *    http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at 
- *   http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- *    Frank Pagliughi - initial implementation and documentation
- *******************************************************************************/
-
-#ifndef __mqtt_topic_h
-#define __mqtt_topic_h
-
-extern "C" {
-	#include "MQTTAsync.h"
-}
-
-#include "mqtt/delivery_token.h"
-#include "mqtt/message.h"
-#include <string>
-#include <vector>
-#include <memory>
-
-namespace mqtt {
-
-class async_client;
-
-/////////////////////////////////////////////////////////////////////////////  
-
-/**
- * Represents a topic destination, used for publish/subscribe messaging. 
- */
-class topic
-{	
-	/// The topic name
-	std::string name_;
-
-	/// The client to which this topic is connected
-	async_client* cli_;
-
-public:
-	/**
-	 * A smart/shared pointer to this class.
-	 */
-	typedef std::shared_ptr<topic> ptr_t;
-	/**
-	 * Construct an MQTT topic destination for messages. 
-	 * @param name 
-	 * @param cli 
-	 */
-	topic(const std::string& name, async_client& cli) : name_(name), cli_(&cli) {}
-	/**
-	 * Returns the name of the queue or topic. 
-	 * @return std::string 
-	 */
-	std::string get_name() const { return name_; }
-	/**
-	 * Publishes a message on the topic.
-	 * @param payload 
-	 * @param n 
-	 * @param qos 
-	 * @param retained 
-	 * 
-	 * @return delivery_token 
-	 */
-	idelivery_token_ptr publish(const void* payload, size_t n, int qos, bool retained);
-	/**
-	 * Publishes a message on the topic.
-	 * @param payload 
-	 * @param qos 
-	 * @param retained 
-	 * 
-	 * @return delivery_token 
-	 */
-	idelivery_token_ptr publish(const std::string& str, int qos, bool retained) {
-		return publish(str.data(), str.length(), qos, retained);
-	}
-	/**
-	 * Publishes the specified message to this topic, but does not wait for 
-	 * delivery of the message to complete. 
-	 * @param message 
-	 * @return delivery_token 
-	 */
-	idelivery_token_ptr publish(message_ptr msg);
-	/**
-	 * Returns a string representation of this topic.
-	 * @return std::string 
-	 */
-	std::string to_str() const { return name_; }
-};
-
-/**
- * A shared pointer to the topic class.
- */
-typedef topic::ptr_t topic_ptr;
-
-/////////////////////////////////////////////////////////////////////////////
-// end namespace mqtt
-}
-
-#endif		// __mqtt_topic_h
-
-- 
2.6.1


Back to the top