diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-08-30 16:36:14 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-08-30 16:36:14 +0200 |
| commit | fff831ff736e90fa6175fcb6f3000408218957e7 (patch) | |
| tree | f48320f1e6ff04a11c38741e9f233634452941d5 /network-handler/client.hpp | |
| parent | 5bac5321fa5ab128cee2f0b8c549945bd6a1ccfc (diff) | |
| download | cmix-fff831ff736e90fa6175fcb6f3000408218957e7.tar.gz cmix-fff831ff736e90fa6175fcb6f3000408218957e7.tar.bz2 cmix-fff831ff736e90fa6175fcb6f3000408218957e7.zip | |
Replaced Client based implementation to composition instead of inheritance.
Diffstat (limited to 'network-handler/client.hpp')
| -rw-r--r-- | network-handler/client.hpp | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/network-handler/client.hpp b/network-handler/client.hpp index fa0c6d6..2b6a6df 100644 --- a/network-handler/client.hpp +++ b/network-handler/client.hpp @@ -8,26 +8,17 @@ 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; - Client() = delete; - Client(Client const&) = delete; - Client(Client&&) = delete; - - Client& operator=(Client const&) = delete; - Client& operator=(Client&&) = delete; - -protected: - virtual void handle_message(std::vector<uint8_t> message) = 0; - public: Client(boost::asio::ip::tcp::socket&& socket); - void handle_receive(boost::system::error_code const& ec, size_t read_bytes); - void receive(); + 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); }; |
