aboutsummaryrefslogtreecommitdiff
path: root/libcmix-network/client.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix-network/client.hpp')
-rw-r--r--libcmix-network/client.hpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp
index 46b989d..981283b 100644
--- a/libcmix-network/client.hpp
+++ b/libcmix-network/client.hpp
@@ -5,22 +5,66 @@
#include <array>
+/*!
+ * \file
+ */
+
+/*!
+ * \brief The Client class
+ */
class Client {
public:
+ /*!
+ * \brief OnDoneFT Function type of the function being called when this instance is done operating.
+ */
typedef std::function<void(void)> OnDoneFT;
+
+ /*!
+ * \brief MessageHandler Function type of the function handling incoming messages.
+ */
typedef std::function<void(std::vector<uint8_t>)> MessageHandler;
protected:
+ /*!
+ * \brief socket The socket connection this instance handles.
+ */
boost::asio::ip::tcp::socket socket;
private:
+ /*!
+ * \brief buffer Internal private buffer used to receive messages.
+ */
boost::asio::streambuf buffer;
+
+ /*!
+ * \brief done The done function being called when this is done operating.
+ */
OnDoneFT done;
+ /*!
+ * \brief handle_receive
+ * \param message_handler The function to call when a message has been received.
+ * \param ec A possible error that occured during receiving.
+ * \param read_bytes The number of bytes read.
+ */
+ void handle_receive(MessageHandler message_handler, boost::system::error_code const& ec, size_t read_bytes);
+
public:
+ /*!
+ * \brief Client
+ * \param socket An rvalue reference to a socket it will now own and receive from.
+ */
Client(boost::asio::ip::tcp::socket&& socket);
-
- void handle_receive(MessageHandler message_handler, boost::system::error_code const& ec, size_t read_bytes);
+
+ /*!
+ * \brief receive
+ * \param message_handler The function to call when a message has been received.
+ */
void receive(MessageHandler message_handler);
+
+ /*!
+ * \brief on_done sets the done callback.
+ * \param f The new done callback function.
+ */
void on_done(OnDoneFT f);
};