what to do on received messages is now handled via template policies
This commit is contained in:
parent
5cfef17cc2
commit
88aff84db1
@ -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 receive_policy = receive_policy_stdout>
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user