added a send() method to the network manager and removed a ctor parameter

This commit is contained in:
Kjistóf 2016-11-29 18:42:38 +01:00
parent 60bb1e6142
commit 8cddc402f1

View File

@ -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()), []{}); });
}
};