TrinityCore
WorldSocket Class Reference

#include <WorldSocket.h>

+ Inheritance diagram for WorldSocket:

Public Member Functions

 WorldSocket (boost::asio::ip::tcp::socket &&socket)
 
 ~WorldSocket ()
 
 WorldSocket (WorldSocket const &right)=delete
 
WorldSocketoperator= (WorldSocket const &right)=delete
 
void Start () override
 
bool Update () override
 
void SendPacket (WorldPacket const &packet)
 
ConnectionType GetConnectionType () const
 
void SendAuthResponseError (uint32 code)
 
void SetWorldSession (WorldSession *session)
 
void SetSendBufferSize (std::size_t sendBufferSize)
 
- Public Member Functions inherited from Socket< WorldSocket >
 Socket (boost::asio::ip::tcp::socket &&socket, Args &&... args)
 
 Socket (Socket const &other)=delete
 
 Socket (Socket &&other)=delete
 
Socketoperator= (Socket const &other)=delete
 
Socketoperator= (Socket &&other)=delete
 
virtual ~Socket ()
 
virtual void Start ()=0
 
virtual bool Update ()
 
boost::asio::ip::address GetRemoteIpAddress () const
 
uint16 GetRemotePort () const
 
void AsyncRead ()
 
void AsyncReadWithCallback (void(T::*callback)(boost::system::error_code const &, std::size_t))
 
void QueuePacket (MessageBuffer &&buffer)
 
bool IsOpen () const
 
void CloseSocket ()
 
void DelayedCloseSocket ()
 Marks the socket for closing after write buffer becomes empty. More...
 
MessageBufferGetReadBuffer ()
 

Protected Types

enum class  ReadDataHandlerResult { Ok = 0 , Error = 1 , WaitingForQuery = 2 }
 

Protected Member Functions

void OnClose () override
 
void ReadHandler () override
 
bool ReadHeaderHandler ()
 
ReadDataHandlerResult ReadDataHandler ()
 
- Protected Member Functions inherited from Socket< WorldSocket >
virtual void OnClose ()
 
virtual void ReadHandler ()=0
 
bool AsyncProcessQueue ()
 
void SetNoDelay (bool enable)
 
boost::asio::ip::tcp::socket & underlying_stream ()
 

Private Types

typedef Socket< WorldSocketBaseSocket
 

Private Member Functions

void CheckIpCallback (PreparedQueryResult result)
 
void InitializeHandler (boost::system::error_code const &error, std::size_t transferedBytes)
 
void LogOpcodeText (OpcodeClient opcode, std::unique_lock< std::mutex > const &guard) const
 
void SendPacketAndLogOpcode (WorldPacket const &packet)
 sends and logs network.opcode without accessing WorldSession More...
 
void WritePacketToBuffer (EncryptablePacket const &packet, MessageBuffer &buffer)
 
uint32 CompressPacket (uint8 *buffer, WorldPacket const &packet)
 
void HandleSendAuthSession ()
 
void HandleAuthSession (std::shared_ptr< WorldPackets::Auth::AuthSession > authSession)
 
void HandleAuthSessionCallback (std::shared_ptr< WorldPackets::Auth::AuthSession > authSession, PreparedQueryResult result)
 
void HandleAuthContinuedSession (std::shared_ptr< WorldPackets::Auth::AuthContinuedSession > authSession)
 
void HandleAuthContinuedSessionCallback (std::shared_ptr< WorldPackets::Auth::AuthContinuedSession > authSession, PreparedQueryResult result)
 
void LoadSessionPermissionsCallback (PreparedQueryResult result)
 
void HandleConnectToFailed (WorldPackets::Auth::ConnectToFailed &connectToFailed)
 
bool HandlePing (WorldPackets::Auth::Ping &ping)
 
void HandleEnterEncryptedModeAck ()
 

Private Attributes

ConnectionType _type
 
uint64 _key
 
std::array< uint8, 16 > _serverChallenge
 
WorldPacketCrypt _authCrypt
 
SessionKey _sessionKey
 
std::array< uint8, 16 > _encryptKey
 
TimePoint _LastPingTime
 
uint32 _OverSpeedPings
 
std::mutex _worldSessionLock
 
WorldSession_worldSession
 
bool _authed
 
bool _canRequestHotfixes
 
MessageBuffer _headerBuffer
 
MessageBuffer _packetBuffer
 
MPSCQueue< EncryptablePacket, &EncryptablePacket::SocketQueueLink_bufferQueue
 
std::size_t _sendBufferSize
 
z_stream_compressionStream
 
QueryCallbackProcessor _queryProcessor
 
std::string _ipCountry
 

Static Private Attributes

static std::string const ServerConnectionInitialize
 
static std::string const ClientConnectionInitialize
 
static uint32 const MinSizeForCompression = 0x400
 
static uint8 const AuthCheckSeed [16] = { 0xC5, 0xC6, 0x98, 0x95, 0x76, 0x3F, 0x1D, 0xCD, 0xB6, 0xA1, 0x37, 0x28, 0xB3, 0x12, 0xFF, 0x8A }
 
static uint8 const SessionKeySeed [16] = { 0x58, 0xCB, 0xCF, 0x40, 0xFE, 0x2E, 0xCE, 0xA6, 0x5A, 0x90, 0xB8, 0x01, 0x68, 0x6C, 0x28, 0x0B }
 
static uint8 const ContinuedSessionSeed [16] = { 0x16, 0xAD, 0x0C, 0xD4, 0x46, 0xF9, 0x4F, 0xB2, 0xEF, 0x7D, 0xEA, 0x2A, 0x17, 0x66, 0x4D, 0x2F }
 
static uint8 const EncryptionKeySeed [16] = { 0xE9, 0x75, 0x3C, 0x50, 0x90, 0x93, 0x61, 0xDA, 0x3B, 0x07, 0xEE, 0xFA, 0xFF, 0x9D, 0x41, 0xB8 }
 

Detailed Description

Definition at line 85 of file WorldSocket.h.

Member Typedef Documentation

◆ BaseSocket

Definition at line 96 of file WorldSocket.h.

Member Enumeration Documentation

◆ ReadDataHandlerResult

enum class WorldSocket::ReadDataHandlerResult
strongprotected
Enumerator
Ok 
Error 
WaitingForQuery 

Definition at line 121 of file WorldSocket.h.

Constructor & Destructor Documentation

◆ WorldSocket() [1/2]

WorldSocket::WorldSocket ( boost::asio::ip::tcp::socket &&  socket)

Definition at line 59 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ ~WorldSocket()

WorldSocket::~WorldSocket ( )

Definition at line 69 of file WorldSocket.cpp.

◆ WorldSocket() [2/2]

WorldSocket::WorldSocket ( WorldSocket const &  right)
delete

Member Function Documentation

◆ CheckIpCallback()

void WorldSocket::CheckIpCallback ( PreparedQueryResult  result)
private

Definition at line 90 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ CompressPacket()

uint32 WorldSocket::CompressPacket ( uint8 buffer,
WorldPacket const &  packet 
)
private

Definition at line 581 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetConnectionType()

ConnectionType WorldSocket::GetConnectionType ( ) const
inline

Definition at line 110 of file WorldSocket.h.

+ Here is the caller graph for this function:

◆ HandleAuthContinuedSession()

void WorldSocket::HandleAuthContinuedSession ( std::shared_ptr< WorldPackets::Auth::AuthContinuedSession authSession)
private

Definition at line 900 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleAuthContinuedSessionCallback()

void WorldSocket::HandleAuthContinuedSessionCallback ( std::shared_ptr< WorldPackets::Auth::AuthContinuedSession authSession,
PreparedQueryResult  result 
)
private

Definition at line 923 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ HandleAuthSession()

void WorldSocket::HandleAuthSession ( std::shared_ptr< WorldPackets::Auth::AuthSession authSession)
private

Definition at line 671 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleAuthSessionCallback()

void WorldSocket::HandleAuthSessionCallback ( std::shared_ptr< WorldPackets::Auth::AuthSession authSession,
PreparedQueryResult  result 
)
private
  • Re-check ip locking (same check as in auth).

Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.

Definition at line 684 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ HandleConnectToFailed()

void WorldSocket::HandleConnectToFailed ( WorldPackets::Auth::ConnectToFailed connectToFailed)
private

Definition at line 967 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleEnterEncryptedModeAck()

void WorldSocket::HandleEnterEncryptedModeAck ( )
private

Definition at line 1005 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlePing()

bool WorldSocket::HandlePing ( WorldPackets::Auth::Ping ping)
private

Definition at line 1021 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleSendAuthSession()

void WorldSocket::HandleSendAuthSession ( )
private

Definition at line 241 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InitializeHandler()

void WorldSocket::InitializeHandler ( boost::system::error_code const &  error,
std::size_t  transferedBytes 
)
private

Definition at line 123 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadSessionPermissionsCallback()

void WorldSocket::LoadSessionPermissionsCallback ( PreparedQueryResult  result)
private

Definition at line 892 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ LogOpcodeText()

void WorldSocket::LogOpcodeText ( OpcodeClient  opcode,
std::unique_lock< std::mutex > const &  guard 
) const
private

writes network.opcode log accessing WorldSession is not threadsafe, only do it when holding _worldSessionLock

Definition at line 507 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OnClose()

void WorldSocket::OnClose ( )
overrideprotectedvirtual

Reimplemented from Socket< WorldSocket >.

Definition at line 251 of file WorldSocket.cpp.

◆ operator=()

WorldSocket & WorldSocket::operator= ( WorldSocket const &  right)
delete

◆ ReadDataHandler()

WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler ( )
protected

Definition at line 352 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadHandler()

void WorldSocket::ReadHandler ( )
overrideprotectedvirtual

Implements Socket< WorldSocket >.

Definition at line 259 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ ReadHeaderHandler()

bool WorldSocket::ReadHeaderHandler ( )
protected

Definition at line 327 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendAuthResponseError()

void WorldSocket::SendAuthResponseError ( uint32  code)

Definition at line 1014 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendPacket()

void WorldSocket::SendPacket ( WorldPacket const &  packet)

Definition at line 526 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendPacketAndLogOpcode()

void WorldSocket::SendPacketAndLogOpcode ( WorldPacket const &  packet)
private

sends and logs network.opcode without accessing WorldSession

Definition at line 520 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetSendBufferSize()

void WorldSocket::SetSendBufferSize ( std::size_t  sendBufferSize)
inline

Definition at line 114 of file WorldSocket.h.

◆ SetWorldSession()

void WorldSocket::SetWorldSession ( WorldSession session)

Definition at line 320 of file WorldSocket.cpp.

◆ Start()

void WorldSocket::Start ( )
overridevirtual

Implements Socket< WorldSocket >.

Definition at line 78 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ Update()

bool WorldSocket::Update ( )
overridevirtual

Reimplemented from Socket< WorldSocket >.

Definition at line 201 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ WritePacketToBuffer()

void WorldSocket::WritePacketToBuffer ( EncryptablePacket const &  packet,
MessageBuffer buffer 
)
private

Definition at line 537 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _authCrypt

WorldPacketCrypt WorldSocket::_authCrypt
private

Definition at line 155 of file WorldSocket.h.

◆ _authed

bool WorldSocket::_authed
private

Definition at line 164 of file WorldSocket.h.

◆ _bufferQueue

MPSCQueue<EncryptablePacket, &EncryptablePacket::SocketQueueLink> WorldSocket::_bufferQueue
private

Definition at line 169 of file WorldSocket.h.

◆ _canRequestHotfixes

bool WorldSocket::_canRequestHotfixes
private

Definition at line 165 of file WorldSocket.h.

◆ _compressionStream

z_stream* WorldSocket::_compressionStream
private

Definition at line 172 of file WorldSocket.h.

◆ _encryptKey

std::array<uint8, 16> WorldSocket::_encryptKey
private

Definition at line 157 of file WorldSocket.h.

◆ _headerBuffer

MessageBuffer WorldSocket::_headerBuffer
private

Definition at line 167 of file WorldSocket.h.

◆ _ipCountry

std::string WorldSocket::_ipCountry
private

Definition at line 175 of file WorldSocket.h.

◆ _key

uint64 WorldSocket::_key
private

Definition at line 152 of file WorldSocket.h.

◆ _LastPingTime

TimePoint WorldSocket::_LastPingTime
private

Definition at line 159 of file WorldSocket.h.

◆ _OverSpeedPings

uint32 WorldSocket::_OverSpeedPings
private

Definition at line 160 of file WorldSocket.h.

◆ _packetBuffer

MessageBuffer WorldSocket::_packetBuffer
private

Definition at line 168 of file WorldSocket.h.

◆ _queryProcessor

QueryCallbackProcessor WorldSocket::_queryProcessor
private

Definition at line 174 of file WorldSocket.h.

◆ _sendBufferSize

std::size_t WorldSocket::_sendBufferSize
private

Definition at line 170 of file WorldSocket.h.

◆ _serverChallenge

std::array<uint8, 16> WorldSocket::_serverChallenge
private

Definition at line 154 of file WorldSocket.h.

◆ _sessionKey

SessionKey WorldSocket::_sessionKey
private

Definition at line 156 of file WorldSocket.h.

◆ _type

ConnectionType WorldSocket::_type
private

Definition at line 151 of file WorldSocket.h.

◆ _worldSession

WorldSession* WorldSocket::_worldSession
private

Definition at line 163 of file WorldSocket.h.

◆ _worldSessionLock

std::mutex WorldSocket::_worldSessionLock
private

Definition at line 162 of file WorldSocket.h.

◆ AuthCheckSeed

uint8 const WorldSocket::AuthCheckSeed = { 0xC5, 0xC6, 0x98, 0x95, 0x76, 0x3F, 0x1D, 0xCD, 0xB6, 0xA1, 0x37, 0x28, 0xB3, 0x12, 0xFF, 0x8A }
staticprivate

Definition at line 91 of file WorldSocket.h.

◆ ClientConnectionInitialize

std::string const WorldSocket::ClientConnectionInitialize
staticprivate

Definition at line 88 of file WorldSocket.h.

◆ ContinuedSessionSeed

uint8 const WorldSocket::ContinuedSessionSeed = { 0x16, 0xAD, 0x0C, 0xD4, 0x46, 0xF9, 0x4F, 0xB2, 0xEF, 0x7D, 0xEA, 0x2A, 0x17, 0x66, 0x4D, 0x2F }
staticprivate

Definition at line 93 of file WorldSocket.h.

◆ EncryptionKeySeed

uint8 const WorldSocket::EncryptionKeySeed = { 0xE9, 0x75, 0x3C, 0x50, 0x90, 0x93, 0x61, 0xDA, 0x3B, 0x07, 0xEE, 0xFA, 0xFF, 0x9D, 0x41, 0xB8 }
staticprivate

Definition at line 94 of file WorldSocket.h.

◆ MinSizeForCompression

uint32 const WorldSocket::MinSizeForCompression = 0x400
staticprivate

Definition at line 89 of file WorldSocket.h.

◆ ServerConnectionInitialize

std::string const WorldSocket::ServerConnectionInitialize
staticprivate

Definition at line 87 of file WorldSocket.h.

◆ SessionKeySeed

uint8 const WorldSocket::SessionKeySeed = { 0x58, 0xCB, 0xCF, 0x40, 0xFE, 0x2E, 0xCE, 0xA6, 0x5A, 0x90, 0xB8, 0x01, 0x68, 0x6C, 0x28, 0x0B }
staticprivate

Definition at line 92 of file WorldSocket.h.


The documentation for this class was generated from the following files: