diff --git a/chat_networking.hpp b/chat_networking.hpp index 7f36689..60da43d 100644 --- a/chat_networking.hpp +++ b/chat_networking.hpp @@ -11,7 +11,7 @@ class client_network_manager using boost::asio::ip::tcp; private: - asio::io_service& _ios; + asio::io_service _ios; tcp::socket _socket; asio::streambuf _sb; std::istream _is{&sb}; @@ -26,10 +26,15 @@ private: } public: - client_network_manager(asio::io_service& ioservice, tcp::resolver::query query) - :_ios(ioservice) + client_network_manager(tcp::resolver::query query) { asio::async_connect(_socket,tcp::resolver().resolve(query), std::bind(&client_network_manager::handshake, this)); } + + void send(chat_message message) + { + _ios.post([this, message] + { asio::async_write(_socket, asio::buffer(message.get()), []{}); }); + } }; \ No newline at end of file