now client_network_manager::receive() actually works

This commit is contained in:
Kjistóf 2016-12-03 13:51:33 +01:00
parent 9c8f985210
commit 096d56d488

View File

@ -37,8 +37,8 @@ namespace chat
std::string receive_message_sync()
{
std::string data;
asio::read_until(_socket, _isb, static_cast<char>(message::TERM));
std::getline(_is, data, static_cast<char>(message::TERM));
asio::read_until(_socket, _isb, byte(message::TERM));
std::getline(_is, data, byte(message::TERM));
return data;
}
@ -64,14 +64,18 @@ namespace chat
void receive()
{
asio::async_read(_socket, _isb,
asio::async_read_until(_socket, _isb, byte(message::TERM),
[this](boost::system::error_code ec, size_t)
{
throw_if_error(ec);
std::string data;
std::getline(_is, data, static_cast<char>(message::TERM));
std::cout << data << std::endl;
std::getline(_is, data, byte(message::TERM));
switch (data[0])
{
// TODO: handle stuff
}
receive();
});