added a send() method to the network manager and removed a ctor parameter
This commit is contained in:
parent
60bb1e6142
commit
8cddc402f1
@ -11,7 +11,7 @@ class client_network_manager
|
|||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
asio::io_service& _ios;
|
asio::io_service _ios;
|
||||||
tcp::socket _socket;
|
tcp::socket _socket;
|
||||||
asio::streambuf _sb;
|
asio::streambuf _sb;
|
||||||
std::istream _is{&sb};
|
std::istream _is{&sb};
|
||||||
@ -26,10 +26,15 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
client_network_manager(asio::io_service& ioservice, tcp::resolver::query query)
|
client_network_manager(tcp::resolver::query query)
|
||||||
:_ios(ioservice)
|
|
||||||
{
|
{
|
||||||
asio::async_connect(_socket,tcp::resolver().resolve(query),
|
asio::async_connect(_socket,tcp::resolver().resolve(query),
|
||||||
std::bind(&client_network_manager::handshake, this));
|
std::bind(&client_network_manager::handshake, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void send(chat_message message)
|
||||||
|
{
|
||||||
|
_ios.post([this, message]
|
||||||
|
{ asio::async_write(_socket, asio::buffer(message.get()), []{}); });
|
||||||
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user