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.hpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp
index 981283b..cb81418 100644
--- a/libcmix-network/client.hpp
+++ b/libcmix-network/client.hpp
@@ -31,24 +31,18 @@ protected:
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;
+
+ std::vector<uint8_t> received_bytes_to_vector(size_t read_bytes);
+
+ void handle_receive_size(MessageHandler message_handler, boost::system::error_code const& ec, size_t read_bytes);
+
+ void handle_receive_message(MessageHandler message_handler, boost::system::error_code const& ec, size_t read_bytes);
- /*!
- * \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);
-
+ std::array<uint8_t, 4> prepare_length_prefix(uint32_t length);
+
public:
/*!
* \brief Client
@@ -56,15 +50,23 @@ public:
*/
Client(boost::asio::ip::tcp::socket&& socket);
+ void async_connect(std::string next_host, std::string next_port, std::function<void()> on_connect);
+
+ void send(std::string message);
+
/*!
* \brief receive
* \param message_handler The function to call when a message has been received.
*/
void receive(MessageHandler message_handler);
+ void close();
+
/*!
* \brief on_done sets the done callback.
* \param f The new done callback function.
*/
void on_done(OnDoneFT f);
+
+
};