mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Networking: Added new AsyncRead method to Socket class allowing to pass a custom completion handler and refactor world socket initialization string handling
This commit is contained in:
@@ -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