diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-16 21:39:18 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-16 21:39:36 +0200 |
| commit | ba6da37569dde1ed7616c14d591134575e6a6879 (patch) | |
| tree | 5562cad589f8c495bd02e61042cf633cd7f0e706 /libcmix-network | |
| parent | c9082aa07394e15cd800bd5ad396c37a2334c98d (diff) | |
| download | cmix-ba6da37569dde1ed7616c14d591134575e6a6879.tar.gz cmix-ba6da37569dde1ed7616c14d591134575e6a6879.tar.bz2 cmix-ba6da37569dde1ed7616c14d591134575e6a6879.zip | |
Updates all the documentation.
Mainly covers the network rewrites.
Diffstat (limited to 'libcmix-network')
| -rw-r--r-- | libcmix-network/client.hpp | 7 | ||||
| -rw-r--r-- | libcmix-network/protobufclient.hpp | 24 |
2 files changed, 28 insertions, 3 deletions
diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp index 4990667..bd66b98 100644 --- a/libcmix-network/client.hpp +++ b/libcmix-network/client.hpp @@ -75,11 +75,10 @@ public: */ void async_connect(std::string next_host, std::string next_port, std::function<void()> on_connect); - inline static void foo() {} - /*! * \brief send sends the string prefixed with it's length over the socket. * \param message The string to be sent. + * \param on_sent The callback to call when the message has been sent. */ template <typename F> void async_send(std::string message, F on_sent) { @@ -125,6 +124,10 @@ public: */ void on_done(OnDoneFT f); + /*! + * \brief is_open + * \return returns true if the underlying socket is opened. + */ bool is_open() const; diff --git a/libcmix-network/protobufclient.hpp b/libcmix-network/protobufclient.hpp index c28c347..247b71f 100644 --- a/libcmix-network/protobufclient.hpp +++ b/libcmix-network/protobufclient.hpp @@ -6,6 +6,15 @@ #include <type_traits> +/*! + * \file + */ + +/*! + * \brief A wrapper around Client that accepts a Functor that can turn specific protobuf messages. + * in to a desired wireformat to serialize and send or receive via the Client. + * \tparam T The Protobuf functor to use when transforming messages. + */ template <typename T> class ProtobufClient : private Client { @@ -14,18 +23,31 @@ public: using Client::operator=; using Client::async_connect; - + /*! + * \brief an async_send wrapper that transforms a specific message to the container message an sends it + * \param value The specific message to send. + * \param on_sent The function to call after succesfully sending the message. + */ template<typename V, typename F> void async_send(V value, F on_sent) { typename T::proto_type m = T()(value); Client::async_send(m.SerializeAsString(), on_sent); } + /*! + * \brief an async_send wrapper, like the above but without the on_sent callback. + * \param value The specific message to send. + */ template<typename V> void async_send(V value) { async_send(value, []{}); } + /*! + * \brief An async_receive wrapper that transforms the wireformat to the protobuf + * container message type. + * \param message_handler The callback to call after receiving a message. + */ template <typename F> void async_receive(F message_handler) { auto f = [message_handler](std::vector<uint8_t> const& buffer) { |
