aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Networking
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-03-10 23:26:26 +0100
committerShauren <shauren.trinity@gmail.com>2016-03-10 23:33:56 +0100
commitf123c396591ffb50fa7e02365235740df618f579 (patch)
tree20eeb1e0c76814267e204b2314cf42db21d5aab4 /src/server/shared/Networking
parent52bb6485417494e58361a75fcf73cf5f0a1d09c5 (diff)
Core/Networking: Added new AsyncRead method to Socket class allowing to pass a custom completion handler and refactor world socket initialization string handling
Diffstat (limited to 'src/server/shared/Networking')
-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 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<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));