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