From a736abb4e3668771f248e7400a093cb40b5313b7 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Mon, 29 Aug 2016 13:29:30 +0200 Subject: Adds the Acceptor and Client class. The acceptor combines the endpoint and acceptor to reduce clutter in NetworkHandler class. The client will handle the connection for the network handler for every separate client. The networkhander now has a std::list of Client, to keep track and ownership of all the Clients. --- network-handler/client.hpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 network-handler/client.hpp (limited to 'network-handler/client.hpp') diff --git a/network-handler/client.hpp b/network-handler/client.hpp new file mode 100644 index 0000000..878c5be --- /dev/null +++ b/network-handler/client.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include + +#include + +class Client { +public: + typedef std::function OnDoneFT; + +private: + boost::asio::ip::tcp::socket socket; + std::array buffer; + OnDoneFT on_done; + + +public: + Client(boost::asio::ip::tcp::socket&& socket); + + void handle_receive(boost::system::error_code const& ec, size_t read_bytes); + void receive(); + void set_on_done(OnDoneFT f); +}; -- cgit v1.2.3-70-g09d2