aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-03-12 23:56:18 +0100
committerShauren <shauren.trinity@gmail.com>2016-03-12 23:56:18 +0100
commit811b29c8e1ebdd0e12a2a3eb7c9586b04d7f5e62 (patch)
tree8b7823e4d30ac7c23dc034c5dc32370f1ed5dcc8
parent55bb3fb00cf55a9a0f3a0579070310bf31f0ac60 (diff)
Core/Networking: Added new AsyncRead method to Socket class allowing to pass a custom completion handler
(Partially cherry-picked from f123c396591ffb50fa7e02365235740df618f579)
-rw-r--r--src/server/shared/Networking/Socket.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h
index c0a08de87e2..0674ede57d8 100644
--- a/src/server/shared/Networking/Socket.h
+++ b/src/server/shared/Networking/Socket.h
@@ -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));