mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 06:36:24 +00:00
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:
@@ -162,7 +162,7 @@ void AccountInfo::LoadResult(Field* fields)
|
||||
Utf8ToUpperOnlyLatin(Login);
|
||||
}
|
||||
|
||||
AuthSession::AuthSession(tcp::socket&& socket) :
|
||||
AuthSession::AuthSession(IoContextTcpSocket&& socket) :
|
||||
Socket(std::move(socket)), _status(STATUS_CHALLENGE), _build(0), _expversion(0) { }
|
||||
|
||||
void AuthSession::Start()
|
||||
@@ -216,7 +216,7 @@ void AuthSession::CheckIpCallback(PreparedQueryResult result)
|
||||
AsyncRead();
|
||||
}
|
||||
|
||||
void AuthSession::ReadHandler()
|
||||
SocketReadCallbackResult AuthSession::ReadHandler()
|
||||
{
|
||||
MessageBuffer& packet = GetReadBuffer();
|
||||
|
||||
@@ -234,7 +234,7 @@ void AuthSession::ReadHandler()
|
||||
if (_status != itr->second.status)
|
||||
{
|
||||
CloseSocket();
|
||||
return;
|
||||
return SocketReadCallbackResult::Stop;
|
||||
}
|
||||
|
||||
uint16 size = uint16(itr->second.packetSize);
|
||||
@@ -248,7 +248,7 @@ void AuthSession::ReadHandler()
|
||||
if (size > MAX_ACCEPTED_CHALLENGE_SIZE)
|
||||
{
|
||||
CloseSocket();
|
||||
return;
|
||||
return SocketReadCallbackResult::Stop;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,13 +258,13 @@ void AuthSession::ReadHandler()
|
||||
if (!(*this.*itr->second.handler)())
|
||||
{
|
||||
CloseSocket();
|
||||
return;
|
||||
return SocketReadCallbackResult::Stop;
|
||||
}
|
||||
|
||||
packet.ReadCompleted(size);
|
||||
}
|
||||
|
||||
AsyncRead();
|
||||
return SocketReadCallbackResult::KeepReading;
|
||||
}
|
||||
|
||||
void AuthSession::SendPacket(ByteBuffer& packet)
|
||||
|
||||
@@ -60,22 +60,22 @@ struct AccountInfo
|
||||
AccountTypes SecurityLevel = SEC_PLAYER;
|
||||
};
|
||||
|
||||
class AuthSession : public Socket<AuthSession>
|
||||
class AuthSession final : public Socket<AuthSession>
|
||||
{
|
||||
typedef Socket<AuthSession> AuthSocket;
|
||||
|
||||
public:
|
||||
static std::unordered_map<uint8, AuthHandler> InitHandlers();
|
||||
|
||||
AuthSession(tcp::socket&& socket);
|
||||
AuthSession(IoContextTcpSocket&& socket);
|
||||
|
||||
void Start() override;
|
||||
bool Update() override;
|
||||
bool Update() final;
|
||||
|
||||
void SendPacket(ByteBuffer& packet);
|
||||
|
||||
protected:
|
||||
void ReadHandler() override;
|
||||
SocketReadCallbackResult ReadHandler() final;
|
||||
|
||||
private:
|
||||
bool HandleLogonChallenge();
|
||||
|
||||
@@ -54,9 +54,9 @@ protected:
|
||||
return threads;
|
||||
}
|
||||
|
||||
static void OnSocketAccept(tcp::socket&& sock, uint32 threadIndex)
|
||||
static void OnSocketAccept(IoContextTcpSocket&& sock, uint32 threadIndex)
|
||||
{
|
||||
Instance().OnSocketOpen(std::forward<tcp::socket>(sock), threadIndex);
|
||||
Instance().OnSocketOpen(std::move(sock), threadIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user