From 88aff84db1e2c1648e8abf2809b8dd24c4b901c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 3 Dec 2016 16:26:13 +0100 Subject: [PATCH] what to do on received messages is now handled via template policies --- chat_networking.hpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/chat_networking.hpp b/chat_networking.hpp index 6135ae4..05b89f0 100644 --- a/chat_networking.hpp +++ b/chat_networking.hpp @@ -15,8 +15,24 @@ namespace chat using boost::asio::ip::tcp; + struct receive_policy_stdout + { + static void message_do_what(chat_message msg) + { + std::cout << msg << '\n'; + } + + // TODO: handshake_policy + }; + + + /* most ezt így üres template paraméterekkel kell példányosítani, + * pl.: client_network_manager<> cnm; + * meg lehet oldani úgy, hogy ne kelljen? usingot/typedefet nem enged saját magára */ + template class client_network_manager { + // TODO: add static assert to check receive_policy /* members */ private: asio::io_service& _ios; @@ -128,7 +144,8 @@ namespace chat send(chat_message(message::PONG)); break; case byte(message::MESSAGE): - std::cout << data << '\n'; + chat_message msg(message::MESSAGE, data); + receive_policy::message_do_what(msg); break; }