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:
Shauren authored and Aokromes committed 2016-05-05 03:41:02 +02:00
1 parent c9e27cca44
commit 049d20fdb7
1 file changed
+11
+11
View File
@@ -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));