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
 
WorldSocket & operator= (WorldSocket const &right)=delete
 
WorldSocket & operator= (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
 
Socket & operator= (Socket const &other)=delete
 
Socket & operator= (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.
 
MessageBuffer & GetReadBuffer ()
 
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.

References _headerBuffer, and MessageBuffer::Resize().

◆ ~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()

◆ 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.

References _authCrypt, _authed, _ipCountry, _serverChallenge, _worldSession, Trinity::Net::Socket< Stream >::AsyncRead(), AUTH_BANNED, AUTH_FAILED, AUTH_REJECT, AUTH_UNAVAILABLE, AUTH_UNKNOWN_ACCOUNT, CONFIG_ALLOW_LOGGING_IP_ADDRESSES_IN_DATABASE, CONFIG_WARDEN_ENABLED, Trinity::Net::Socket< Stream >::DelayedCloseSocket(), AccountInfo::Expansion, Trinity::Impl::GenericHash< HashCreator, DigestLength >::Finalize(), Trinity::Impl::GenericHash< HashCreator, DigestLength >::GetDigest(), GameTime::GetGameTime(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), AccountInfo::Id, Realm::Id, WorldPacketCrypt::Init(), WorldSession::InitWarden(), AccountInfo::IsBanned, AccountInfo::IsLockedToIP, AccountInfo::IsRectuiter, ClientBuild::Platform::IsValid(), AccountInfo::LastIP, WorldSession::LoadPermissionsAsync(), LoadSessionPermissionsCallback(), AccountInfo::Locale, AccountInfo::LockCountry, LOGIN_UPD_LAST_ATTEMPT_IP, LOGIN_UPD_LAST_IP, LOGIN_UPD_MUTE_TIME_LOGIN, LoginDatabase, AccountInfo::MuteTime, AccountInfo::OS, QueueQuery(), WorldSession::ReadAddonsInfo(), realm, RealmHandle::Realm, REALM_LIST_REALM_NOT_FOUND, AccountInfo::Recruiter, SEC_PLAYER, AccountInfo::Security, SendAuthResponseError(), AccountInfo::SessionKey, PreparedStatementBase::setInt64(), PreparedStatementBase::setString(), PreparedStatementBase::setUInt32(), sIPLocation, Trinity::Net::InvokeReadHandlerCallback< SocketType >::Socket, sScriptMgr, sWorld, TC_LOG_DEBUG, TC_LOG_ERROR, AccountInfo::TimezoneOffset, Trinity::Impl::GenericHash< HashCreator, DigestLength >::UpdateData(), and QueryCallback::WithPreparedCallback().

◆ HandlePing()

◆ LoadSessionPermissionsCallback()

void WorldSocket::LoadSessionPermissionsCallback ( PreparedQueryResult  result)
private

◆ 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.

References _worldSession, GetOpcodeNameForLogging(), WorldSession::GetPlayerInfo(), Trinity::Net::Socket< Stream >::GetRemoteIpAddress(), and TC_LOG_TRACE.

Referenced by ReadDataHandler().

◆ OnClose()

void WorldSocket::OnClose ( )
overridevirtual

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

Definition at line 136 of file WorldSocket.cpp.

References _worldSession, and _worldSessionLock.

◆ 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)

◆ ReadDataHandler()

◆ ReadHandler()

◆ ReadHeaderHandler()

◆ SendAuthResponseError()

void WorldSocket::SendAuthResponseError ( uint8  code)
private

Definition at line 632 of file WorldSocket.cpp.

References SendPacketAndLogOpcode(), and SMSG_AUTH_RESPONSE.

Referenced by HandleAuthSessionCallback().

◆ SendAuthSession()

◆ SendPacket()

◆ SendPacketAndLogOpcode()

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

◆ 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.

References Trinity::Net::SocketConnectionInitializer::SetupChain(), and Start().

Referenced by Start().

◆ Update()

Member Data Documentation

◆ _authCrypt

WorldPacketCrypt WorldSocket::_authCrypt
private

Definition at line 121 of file WorldSocket.h.

Referenced by HandleAuthSessionCallback(), ReadHeaderHandler(), SendPacket(), and Update().

◆ _authed

bool WorldSocket::_authed
private

Definition at line 128 of file WorldSocket.h.

Referenced by HandleAuthSessionCallback(), and ReadDataHandler().

◆ _bufferQueue

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

Definition at line 132 of file WorldSocket.h.

Referenced by SendPacket(), and Update().

◆ _dosChallenge

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

Definition at line 120 of file WorldSocket.h.

Referenced by SendAuthSession().

◆ _headerBuffer

MessageBuffer WorldSocket::_headerBuffer
private

Definition at line 130 of file WorldSocket.h.

Referenced by ReadDataHandler(), ReadHandler(), ReadHeaderHandler(), and WorldSocket().

◆ _ipCountry

std::string WorldSocket::_ipCountry
private

Definition at line 136 of file WorldSocket.h.

Referenced by HandleAuthSessionCallback().

◆ _LastPingTime

TimePoint WorldSocket::_LastPingTime
private

Definition at line 123 of file WorldSocket.h.

Referenced by HandlePing().

◆ _OverSpeedPings

uint32 WorldSocket::_OverSpeedPings
private

Definition at line 124 of file WorldSocket.h.

Referenced by HandlePing().

◆ _packetBuffer

MessageBuffer WorldSocket::_packetBuffer
private

Definition at line 131 of file WorldSocket.h.

Referenced by ReadDataHandler(), ReadHandler(), and ReadHeaderHandler().

◆ _queryProcessor

QueryCallbackProcessor WorldSocket::_queryProcessor
private

Definition at line 135 of file WorldSocket.h.

Referenced by QueueQuery(), and Update().

◆ _sendBufferSize

std::size_t WorldSocket::_sendBufferSize
private

Definition at line 133 of file WorldSocket.h.

Referenced by Update().

◆ _serverChallenge

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

Definition at line 119 of file WorldSocket.h.

Referenced by HandleAuthSessionCallback(), and SendAuthSession().

◆ _worldSession

WorldSession* WorldSocket::_worldSession
private

◆ _worldSessionLock

std::mutex WorldSocket::_worldSessionLock
private

Definition at line 126 of file WorldSocket.h.

Referenced by HandlePing(), OnClose(), and ReadDataHandler().


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