refactor(Core/Network): Port TrinityCore socket optimizations (#24384)

Co-authored-by: blinkysc <blinkysc@users.noreply.github.com>
Co-authored-by: Shauren <shauren@users.noreply.github.com>
This commit is contained in:
blinkysc
2026-01-15 07:47:58 -06:00
committed by GitHub
parent a8ce95ad71
commit d908b4c2fc
16 changed files with 242 additions and 75 deletions

View File

@@ -116,7 +116,7 @@ void EncryptableAndCompressiblePacket::CompressIfNeeded()
SetOpcode(SMSG_COMPRESSED_UPDATE_OBJECT);
}
WorldSocket::WorldSocket(tcp::socket&& socket)
WorldSocket::WorldSocket(IoContextTcpSocket&& socket)
: Socket(std::move(socket)), _OverSpeedPings(0), _worldSession(nullptr), _authed(false), _sendBufferSize(4096), _loggingPackets(false)
{
Acore::Crypto::GetRandomBytes(_authSeed);
@@ -238,10 +238,10 @@ void WorldSocket::OnClose()
}
}
void WorldSocket::ReadHandler()
SocketReadCallbackResult WorldSocket::ReadHandler()
{
if (!IsOpen())
return;
return SocketReadCallbackResult::Stop;
MessageBuffer& packet = GetReadBuffer();
while (packet.GetActiveSize() > 0)
@@ -264,7 +264,7 @@ void WorldSocket::ReadHandler()
if (!ReadHeaderHandler())
{
CloseSocket();
return;
return SocketReadCallbackResult::Stop;
}
}
@@ -295,11 +295,11 @@ void WorldSocket::ReadHandler()
CloseSocket();
}
return;
return SocketReadCallbackResult::Stop;
}
}
AsyncRead();
return SocketReadCallbackResult::KeepReading;
}
bool WorldSocket::ReadHeaderHandler()