completed TODO: handshaking messages are now handled by receive policy
This commit is contained in:
parent
e03a3e9aa3
commit
7eb1191a1d
@ -22,7 +22,8 @@ namespace chat
|
||||
static void message_do_what(chat_message msg)
|
||||
{ std::cout << msg << '\n'; }
|
||||
|
||||
// TODO: handshake_policy
|
||||
static void handshake_do_what(chat_message msg)
|
||||
{ message_do_what(msg); }
|
||||
};
|
||||
|
||||
|
||||
@ -109,11 +110,11 @@ namespace chat
|
||||
_os << chat_message(message::PASSW, _login);
|
||||
asio::write(_socket, _osb); // handshake is handled synchronously
|
||||
|
||||
// TODO: do something with these couts (decide whether to display this or not)
|
||||
std::cout << receive_message_sync() << '\n';
|
||||
std::cout << receive_message_sync() << '\n';
|
||||
std::cout << receive_message_sync() << '\n';
|
||||
std::cout << receive_message_sync() << '\n';
|
||||
std::string data;
|
||||
for (int i = 0; i < 4; ++i) // hello + 3 responses for messages above
|
||||
data += receive_message_sync() += '\n';
|
||||
|
||||
receive_policy::handshake_do_what(chat_message(message::SERVER_DIRECTION, data));
|
||||
|
||||
receive(); // then flow goes to receive-loop
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
|
||||
/* SFINAE compile-type checker for receive policies (as defined in chat_networking.hpp)
|
||||
* it checks whether PolicyCandidate supplies all of the following methods:
|
||||
* - void message_do_what(chat_message) */
|
||||
* - void message_do_what(chat_message)
|
||||
* - void handshake_do_what(chat_message) */
|
||||
template <class PolicyCandidate, typename = void>
|
||||
struct is_valid_policy : std::false_type {};
|
||||
|
||||
@ -20,5 +21,11 @@ struct is_valid_policy<
|
||||
::message_do_what(std::declval<chat::chat_message>())),
|
||||
void
|
||||
>::value
|
||||
&&
|
||||
std::is_same<
|
||||
decltype(PolicyCandidate
|
||||
::handshake_do_what(std::declval<chat::chat_message>())),
|
||||
void
|
||||
>::value
|
||||
>::type>
|
||||
: std::true_type {};
|
Loading…
Reference in New Issue
Block a user