aboutsummaryrefslogtreecommitdiff
path: root/libcmix-network/client.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-08-31 11:57:15 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-08-31 11:57:15 +0200
commit2f1c3293d2c5776c4ecd9b2f1dce66492b15dbdd (patch)
tree1c582e4c5715a93c493582b1e01e51bc960d56c0 /libcmix-network/client.hpp
parent1525c5defe3db08c765477003be73c68bb2c3cb7 (diff)
downloadcmix-2f1c3293d2c5776c4ecd9b2f1dce66492b15dbdd.tar.gz
cmix-2f1c3293d2c5776c4ecd9b2f1dce66492b15dbdd.tar.bz2
cmix-2f1c3293d2c5776c4ecd9b2f1dce66492b15dbdd.zip
Split up the client and server parts in a separate network library
Diffstat (limited to 'libcmix-network/client.hpp')
-rw-r--r--libcmix-network/client.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/libcmix-network/client.hpp b/libcmix-network/client.hpp
new file mode 100644
index 0000000..2b6a6df
--- /dev/null
+++ b/libcmix-network/client.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/streambuf.hpp>
+
+#include <array>
+
+class Client {
+public:
+ typedef std::function<void(void)> OnDoneFT;
+ typedef std::function<void(std::vector<uint8_t>)> MessageHandler;
+
+private:
+ boost::asio::ip::tcp::socket socket;
+ boost::asio::streambuf buffer;
+ OnDoneFT done;
+
+public:
+ Client(boost::asio::ip::tcp::socket&& socket);
+
+ void handle_receive(MessageHandler message_handler, boost::system::error_code const& ec, size_t read_bytes);
+ void receive(MessageHandler message_handler);
+ void on_done(OnDoneFT f);
+};