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 receive_message_sync()
{ {
std::string data; std::string data;
asio::read_until(_socket, _isb, static_cast<char>(message::TERM)); asio::read_until(_socket, _isb, byte(message::TERM));
std::getline(_is, data, static_cast<char>(message::TERM)); std::getline(_is, data, byte(message::TERM));
return data; return data;
} }
@ -64,17 +64,21 @@ namespace chat
void receive() void receive()
{ {
asio::async_read(_socket, _isb, asio::async_read_until(_socket, _isb, byte(message::TERM),
[this](boost::system::error_code ec, size_t) [this](boost::system::error_code ec, size_t)
{ {
throw_if_error(ec); throw_if_error(ec);
std::string data; std::string data;
std::getline(_is, data, static_cast<char>(message::TERM)); std::getline(_is, data, byte(message::TERM));
std::cout << data << std::endl;
receive(); switch (data[0])
}); {
// TODO: handle stuff
}
receive();
});
} }
void connect(tcp::resolver::iterator epit) void connect(tcp::resolver::iterator epit)