From f123c396591ffb50fa7e02365235740df618f579 Mon Sep 17 00:00:00 2001 From: Shauren Date: Thu, 10 Mar 2016 23:26:26 +0100 Subject: Core/Networking: Added new AsyncRead method to Socket class allowing to pass a custom completion handler and refactor world socket initialization string handling --- src/server/shared/Networking/Socket.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/server/shared') diff --git a/src/server/shared/Networking/Socket.h b/src/server/shared/Networking/Socket.h index 07f427652aa..80655441ec2 100644 --- a/src/server/shared/Networking/Socket.h +++ b/src/server/shared/Networking/Socket.h @@ -90,6 +90,17 @@ public: std::bind(&Socket::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)); -- cgit v1.2.3