TrinityCore
Loading...
Searching...
No Matches
WorldSocket Class Referencefinal

#include <WorldSocket.h>

+ Inheritance diagram for WorldSocket:

Public Member Functions

 WorldSocket (Trinity::Net::IoContextTcpSocket &&socket)
 
 ~WorldSocket ()
 
 WorldSocket (WorldSocket const &right)=delete
 
 WorldSocket (WorldSocket &&right)=delete
 
WorldSocketoperator= (WorldSocket const &right)=delete
 
WorldSocketoperator= (WorldSocket &&right)=delete
 
void Start () override
 
bool Update () override
 
void SendPacket (WorldPacket const &packet)
 
void SetSendBufferSize (std::size_t sendBufferSize)
 
void OnClose () override
 
Trinity::Net::SocketReadCallbackResult ReadHandler () override
 
void QueueQuery (QueryCallback &&queryCallback)
 
void SendAuthSession ()
 
- Public Member Functions inherited from Trinity::Net::Socket< Stream >
template<typename... Args>
 Socket (IoContextTcpSocket &&socket, Args &&... args)
 
template<typename... Args>
 Socket (boost::asio::io_context &context, Args &&... args)
 
 Socket (Socket const &other)=delete
 
 Socket (Socket &&other)=delete
 
Socketoperator= (Socket const &other)=delete
 
Socketoperator= (Socket &&other)=delete
 
virtual ~Socket ()
 
boost::asio::ip::address const & GetRemoteIpAddress () const
 
uint16 GetRemotePort () const
 
template<SocketReadCallback Callback>
void AsyncRead (Callback &&callback)
 
void QueuePacket (MessageBuffer &&buffer)
 
bool IsOpen () const
 
void CloseSocket ()
 
void DelayedCloseSocket ()
 Marks the socket for closing after write buffer becomes empty.
 
MessageBufferGetReadBuffer ()
 
Stream & underlying_stream ()
 

Protected Types

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

Protected Member Functions

bool ReadHeaderHandler ()
 
ReadDataHandlerResult ReadDataHandler ()
 
- Protected Member Functions inherited from Trinity::Net::Socket< Stream >
bool AsyncProcessQueue ()
 
void SetNoDelay (bool enable)
 

Private Types

using BaseSocket = Socket
 

Private Member Functions

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
 
void HandleAuthSession (WorldPacket &recvPacket)
 
void HandleAuthSessionCallback (std::shared_ptr< AuthSession > authSession, PreparedQueryResult result)
 
void LoadSessionPermissionsCallback (PreparedQueryResult result)
 
void SendAuthResponseError (uint8 code)
 
bool HandlePing (WorldPacket &recvPacket)
 

Private Attributes

std::array< uint8, 4 > _serverChallenge
 
std::array< uint8, 32 > _dosChallenge
 
WorldPacketCrypt _authCrypt
 
TimePoint _LastPingTime
 
uint32 _OverSpeedPings
 
std::mutex _worldSessionLock
 
WorldSession_worldSession
 
bool _authed
 
MessageBuffer _headerBuffer
 
MessageBuffer _packetBuffer
 
MPSCQueue< EncryptablePacket, &EncryptablePacket::SocketQueueLink_bufferQueue
 
std::size_t _sendBufferSize
 
QueryCallbackProcessor _queryProcessor
 
std::string _ipCountry
 

Detailed Description

Definition at line 67 of file WorldSocket.h.

Member Typedef Documentation

◆ BaseSocket

Definition at line 69 of file WorldSocket.h.

Member Enumeration Documentation

◆ ReadDataHandlerResult

enum class WorldSocket::ReadDataHandlerResult
strongprotected
Enumerator
Ok 
Error 
WaitingForQuery 

Definition at line 97 of file WorldSocket.h.

Constructor & Destructor Documentation

◆ WorldSocket() [1/3]

WorldSocket::WorldSocket ( Trinity::Net::IoContextTcpSocket &&  socket)

Definition at line 37 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ ~WorldSocket()

WorldSocket::~WorldSocket ( )
default

◆ WorldSocket() [2/3]

WorldSocket::WorldSocket ( WorldSocket const &  right)
delete

◆ WorldSocket() [3/3]

WorldSocket::WorldSocket ( WorldSocket &&  right)
delete

Member Function Documentation

◆ HandleAuthSession()

void WorldSocket::HandleAuthSession ( WorldPacket recvPacket)
private

Definition at line 423 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< 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 452 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ HandlePing()

bool WorldSocket::HandlePing ( WorldPacket recvPacket)
private

Definition at line 640 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 624 of file WorldSocket.cpp.

+ Here is the call graph for this function:
+ Here is the caller 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 394 of file WorldSocket.cpp.

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

◆ OnClose()

void WorldSocket::OnClose ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 136 of file WorldSocket.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ QueueQuery()

void WorldSocket::QueueQuery ( QueryCallback &&  queryCallback)

Definition at line 202 of file WorldSocket.cpp.

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

◆ ReadDataHandler()

WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler ( )
protected

Definition at line 297 of file WorldSocket.cpp.

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

◆ ReadHandler()

Trinity::Net::SocketReadCallbackResult WorldSocket::ReadHandler ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 144 of file WorldSocket.cpp.

+ Here is the call graph for this function:

◆ ReadHeaderHandler()

bool WorldSocket::ReadHeaderHandler ( )
protected

Definition at line 207 of file WorldSocket.cpp.

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

◆ SendAuthResponseError()

void WorldSocket::SendAuthResponseError ( uint8  code)
private

Definition at line 632 of file WorldSocket.cpp.

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

◆ SendAuthSession()

void WorldSocket::SendAuthSession ( )

Definition at line 123 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 412 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 406 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 85 of file WorldSocket.h.

◆ Start()

void WorldSocket::Start ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 60 of file WorldSocket.cpp.

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

◆ Update()

bool WorldSocket::Update ( )
overridevirtual

Reimplemented from Trinity::Net::Socket< Stream >.

Definition at line 73 of file WorldSocket.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ _authCrypt

WorldPacketCrypt WorldSocket::_authCrypt
private

Definition at line 121 of file WorldSocket.h.

◆ _authed

bool WorldSocket::_authed
private

Definition at line 128 of file WorldSocket.h.

◆ _bufferQueue

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

Definition at line 132 of file WorldSocket.h.

◆ _dosChallenge

std::array<uint8, 32> WorldSocket::_dosChallenge
private

Definition at line 120 of file WorldSocket.h.

◆ _headerBuffer

MessageBuffer WorldSocket::_headerBuffer
private

Definition at line 130 of file WorldSocket.h.

◆ _ipCountry

std::string WorldSocket::_ipCountry
private

Definition at line 136 of file WorldSocket.h.

◆ _LastPingTime

TimePoint WorldSocket::_LastPingTime
private

Definition at line 123 of file WorldSocket.h.

◆ _OverSpeedPings

uint32 WorldSocket::_OverSpeedPings
private

Definition at line 124 of file WorldSocket.h.

◆ _packetBuffer

MessageBuffer WorldSocket::_packetBuffer
private

Definition at line 131 of file WorldSocket.h.

◆ _queryProcessor

QueryCallbackProcessor WorldSocket::_queryProcessor
private

Definition at line 135 of file WorldSocket.h.

◆ _sendBufferSize

std::size_t WorldSocket::_sendBufferSize
private

Definition at line 133 of file WorldSocket.h.

◆ _serverChallenge

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

Definition at line 119 of file WorldSocket.h.

◆ _worldSession

WorldSession* WorldSocket::_worldSession
private

Definition at line 127 of file WorldSocket.h.

◆ _worldSessionLock

std::mutex WorldSocket::_worldSessionLock
private

Definition at line 126 of file WorldSocket.h.


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