From 096d56d488e1954fac7ed0e899e8606903fd7cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 3 Dec 2016 13:51:33 +0100 Subject: [PATCH] now client_network_manager::receive() actually works --- chat_networking.hpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/chat_networking.hpp b/chat_networking.hpp index 957fdd8..5433b39 100644 --- a/chat_networking.hpp +++ b/chat_networking.hpp @@ -37,8 +37,8 @@ namespace chat std::string receive_message_sync() { std::string data; - asio::read_until(_socket, _isb, static_cast(message::TERM)); - std::getline(_is, data, static_cast(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(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)