now client_network_manager::receive() actually works
This commit is contained in:
parent
9c8f985210
commit
096d56d488
@ -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,17 +64,21 @@ namespace chat
|
||||
|
||||
void receive()
|
||||
{
|
||||
asio::async_read(_socket, _isb,
|
||||
[this](boost::system::error_code ec, size_t)
|
||||
{
|
||||
throw_if_error(ec);
|
||||
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::string data;
|
||||
std::getline(_is, data, byte(message::TERM));
|
||||
|
||||
receive();
|
||||
});
|
||||
switch (data[0])
|
||||
{
|
||||
// TODO: handle stuff
|
||||
}
|
||||
|
||||
receive();
|
||||
});
|
||||
}
|
||||
|
||||
void connect(tcp::resolver::iterator epit)
|
||||
|
Loading…
Reference in New Issue
Block a user