Core/Networking: Added new AsyncRead method to Socket class allowing to pass a custom completion handler
(Partially cherry-picked from f123c396591ffb50fa7e02365235740df618f579)
This commit is contained in:
1 parent
c9e27cca44
commit
049d20fdb7
1 file changed
+11
@@ -90,6 +90,17 @@ public:
|
||||
std::bind(&Socket<T>::ReadHandlerInternal, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
void AsyncReadWithCallback(void (T::*callback)(boost::system::error_code, std::size_t))
|
||||
{
|
||||
if (!IsOpen())
|
||||
return;
|
||||
|
||||
_readBuffer.Normalize();
|
||||
_readBuffer.EnsureFreeSpace();
|
||||
_socket.async_read_some(boost::asio::buffer(_readBuffer.GetWritePointer(), _readBuffer.GetRemainingSpace()),
|
||||
std::bind(callback, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
void QueuePacket(MessageBuffer&& buffer)
|
||||
{
|
||||
_writeQueue.push(std::move(buffer));
|
||||
|
||||
Reference in new issue
Block a user