TrinityCore
Loading...
Searching...
No Matches
Battlenet::Session Class Referencefinal

#include <Session.h>

+ Inheritance diagram for Battlenet::Session:

Public Member Functions

 Session (Trinity::Net::IoContextTcpSocket &&socket)
 
 ~Session ()
 
void Start ()
 
bool Update ()
 
boost::asio::ip::address const & GetRemoteIpAddress () const
 
bool IsOpen () const
 
void CloseSocket ()
 
void DelayedCloseSocket ()
 
bool IsAuthed () const
 
uint32 GetSessionId () const
 
SystemTimePoint GetCreationTime () const
 
void SetClientInstanceId (std::string const &ciid)
 
uint32 GetAccountId () const
 
AccountInfo const * GetAccountInfo () const
 
uint32 GetGameAccountId () const
 
GameAccountInfo const * GetGameAccountInfo () const
 
GameAccountInfo const * GetGameAccountInfo (uint32 gameAccountId) const
 
LastPlayedCharacterInfo const * GetLastPlayedCharacter (std::string_view subRegion) const
 
std::string const & GetLocale () const
 
std::string const & GetOS () const
 
uint32 GetBuild () const
 
ClientBuild::VariantId GetBuildVariant () const
 
Minutes GetTimezoneOffset () const
 
std::array< uint8, 32 > GetClientSecret () const
 
void SendResponse (uint32 token, pb::Message const *response)
 
void SendResponse (uint32 token, uint32 status)
 
void SendRequest (uint32 serviceHash, uint32 methodId, pb::Message const *request, std::function< void(MessageBuffer)> callback)
 
void SendRequest (uint32 serviceHash, uint32 methodId, pb::Message const *request)
 
void QueueQuery (QueryCallback &&queryCallback)
 
void OnLogon (std::string_view platform, std::string_view locale, uint32 applicationVersion, Minutes timezoneOffset)
 
void OnLogonSuccess (std::shared_ptr< AccountInfo > accountInfo, std::string_view ipCountry)
 
void SetClientInfo (uint32 gameAccountId, ClientBuild::VariantId buildVariant, std::array< uint8, 32 > const &clientSecret)
 
std::string GetClientInfo () const
 
Trinity::Net::SocketReadCallbackResult ReadHandler ()
 

Protected Member Functions

bool ReadHeaderLengthHandler ()
 
bool ReadHeaderHandler ()
 
bool ReadDataHandler ()
 

Private Types

enum class  PacketReadState { HeaderLength , Header , Data }
 
using Socket = Trinity::Net::Socket< Trinity::Net::SslStream<> >
 

Private Member Functions

void AsyncWrite (MessageBuffer *packet)
 

Static Private Member Functions

static std::shared_ptr< Socket > CreateSocket (Trinity::Net::IoContextTcpSocket &&socket)
 

Private Attributes

std::shared_ptr< Socket > _socket
 
PacketReadState _packetReadState
 
MessageBuffer _packetBuffer
 
uint32 const _sessionId
 
SystemTimePoint const _creationTime
 
std::string _clientInstanceId
 
std::shared_ptr< AccountInfo > _accountInfo
 
GameAccountInfo const * _gameAccountInfo
 
std::string _locale
 
std::string _os
 
uint32 _build
 
ClientBuild::VariantId _buildVariant
 
Minutes _timezoneOffset
 
std::string _ipCountry
 
std::array< uint8, 32 > _clientSecret
 
bool _authed
 
QueryCallbackProcessor _queryProcessor
 
std::unordered_map< uint32, std::function< void(MessageBuffer)> > _responseCallbacks
 
uint32 _requestToken
 

Detailed Description

Definition at line 81 of file Session.h.

Member Typedef Documentation

◆ Socket

Definition at line 139 of file Session.h.

Member Enumeration Documentation

◆ PacketReadState

enum class Battlenet::Session::PacketReadState
strongprivate
Enumerator
HeaderLength 
Header 
Data 

Definition at line 144 of file Session.h.

Constructor & Destructor Documentation

◆ Session()

Battlenet::Session::Session ( Trinity::Net::IoContextTcpSocket &&  socket)
explicit

Definition at line 73 of file Session.cpp.

◆ ~Session()

Battlenet::Session::~Session ( )
default

Member Function Documentation

◆ AsyncWrite()

void Battlenet::Session::AsyncWrite ( MessageBuffer *  packet)
private

Definition at line 121 of file Session.cpp.

◆ CloseSocket()

void Battlenet::Session::CloseSocket ( )
inline

Definition at line 91 of file Session.h.

References _socket.

Referenced by PartialProcessPacket().

◆ CreateSocket()

std::shared_ptr< Battlenet::Session::Socket > Battlenet::Session::CreateSocket ( Trinity::Net::IoContextTcpSocket &&  socket)
staticprivate

Definition at line 83 of file Session.cpp.

References Battlenet::SslContext::instance().

◆ DelayedCloseSocket()

void Battlenet::Session::DelayedCloseSocket ( )
inline

Definition at line 92 of file Session.h.

References _socket.

Referenced by Battlenet::Services::V1::Connection::HandleRequestDisconnect().

◆ GetAccountId()

◆ GetAccountInfo()

AccountInfo const * Battlenet::Session::GetAccountInfo ( ) const
inline

Definition at line 101 of file Session.h.

References _accountInfo.

◆ GetBuild()

◆ GetBuildVariant()

ClientBuild::VariantId Battlenet::Session::GetBuildVariant ( ) const
inline

Definition at line 111 of file Session.h.

References _buildVariant.

Referenced by Battlenet::Services::Shared::GameUtilities::JoinRealm().

◆ GetClientInfo()

◆ GetClientSecret()

std::array< uint8, 32 > Battlenet::Session::GetClientSecret ( ) const
inline

Definition at line 113 of file Session.h.

References _clientSecret.

Referenced by Battlenet::Services::Shared::GameUtilities::JoinRealm().

◆ GetCreationTime()

SystemTimePoint Battlenet::Session::GetCreationTime ( ) const
inline

Definition at line 97 of file Session.h.

References _creationTime.

Referenced by Battlenet::Services::V1::Connection::HandleConnect().

◆ GetGameAccountId()

uint32 Battlenet::Session::GetGameAccountId ( ) const
inline

Definition at line 103 of file Session.h.

References _gameAccountInfo, and Battlenet::GameAccountInfo::Id.

◆ GetGameAccountInfo() [1/2]

◆ GetGameAccountInfo() [2/2]

Battlenet::GameAccountInfo const * Battlenet::Session::GetGameAccountInfo ( uint32  gameAccountId) const

Definition at line 113 of file Session.cpp.

References Trinity::Containers::MapGetValuePtr().

◆ GetLastPlayedCharacter()

Battlenet::LastPlayedCharacterInfo const * Battlenet::Session::GetLastPlayedCharacter ( std::string_view  subRegion) const

◆ GetLocale()

std::string const & Battlenet::Session::GetLocale ( ) const
inline

◆ GetOS()

std::string const & Battlenet::Session::GetOS ( ) const
inline

◆ GetRemoteIpAddress()

boost::asio::ip::address const & Battlenet::Session::GetRemoteIpAddress ( ) const
inline

◆ GetSessionId()

uint32 Battlenet::Session::GetSessionId ( ) const
inline

Definition at line 96 of file Session.h.

References _sessionId.

Referenced by Battlenet::Services::V1::Connection::HandleConnect().

◆ GetTimezoneOffset()

Minutes Battlenet::Session::GetTimezoneOffset ( ) const
inline

Definition at line 112 of file Session.h.

References _timezoneOffset.

Referenced by Battlenet::Services::Shared::GameUtilities::JoinRealm().

◆ IsAuthed()

◆ IsOpen()

bool Battlenet::Session::IsOpen ( ) const
inline

Definition at line 90 of file Session.h.

References _socket.

◆ OnLogon()

void Battlenet::Session::OnLogon ( std::string_view  platform,
std::string_view  locale,
uint32  applicationVersion,
Minutes  timezoneOffset 
)

◆ OnLogonSuccess()

void Battlenet::Session::OnLogonSuccess ( std::shared_ptr< AccountInfo >  accountInfo,
std::string_view  ipCountry 
)

Definition at line 223 of file Session.cpp.

◆ QueueQuery()

void Battlenet::Session::QueueQuery ( QueryCallback &&  queryCallback)

◆ ReadDataHandler()

bool Battlenet::Session::ReadDataHandler ( )
protected

Definition at line 322 of file Session.cpp.

References ASSERT, PacketHeaderLengthSize, and sServiceDispatcher.

◆ ReadHandler()

Trinity::Net::SocketReadCallbackResult Battlenet::Session::ReadHandler ( )

Definition at line 272 of file Session.cpp.

References MessageBuffer::GetActiveSize(), and Trinity::Net::KeepReading.

◆ ReadHeaderHandler()

bool Battlenet::Session::ReadHeaderHandler ( )
protected

Definition at line 309 of file Session.cpp.

◆ ReadHeaderLengthHandler()

bool Battlenet::Session::ReadHeaderLengthHandler ( )
protected

◆ SendRequest() [1/2]

void Battlenet::Session::SendRequest ( uint32  serviceHash,
uint32  methodId,
pb::Message const *  request 
)

◆ SendRequest() [2/2]

void Battlenet::Session::SendRequest ( uint32  serviceHash,
uint32  methodId,
pb::Message const *  request,
std::function< void(MessageBuffer)>  callback 
)

Definition at line 176 of file Session.cpp.

Referenced by Battlenet::ServiceBaseCaller::SendRequest().

◆ SendResponse() [1/2]

void Battlenet::Session::SendResponse ( uint32  token,
pb::Message const *  response 
)

◆ SendResponse() [2/2]

void Battlenet::Session::SendResponse ( uint32  token,
uint32  status 
)

◆ SetClientInfo()

void Battlenet::Session::SetClientInfo ( uint32  gameAccountId,
ClientBuild::VariantId  buildVariant,
std::array< uint8, 32 > const &  clientSecret 
)

◆ SetClientInstanceId()

void Battlenet::Session::SetClientInstanceId ( std::string const &  ciid)
inline

Definition at line 98 of file Session.h.

References _clientInstanceId.

Referenced by Battlenet::Services::V1::Connection::HandleConnect().

◆ Start()

◆ Update()

bool Battlenet::Session::Update ( )

Definition at line 103 of file Session.cpp.

Member Data Documentation

◆ _accountInfo

std::shared_ptr<AccountInfo> Battlenet::Session::_accountInfo
private

Definition at line 158 of file Session.h.

Referenced by GetAccountId(), and GetAccountInfo().

◆ _authed

bool Battlenet::Session::_authed
private

Definition at line 171 of file Session.h.

Referenced by IsAuthed().

◆ _build

uint32 Battlenet::Session::_build
private

Definition at line 163 of file Session.h.

Referenced by GetBuild().

◆ _buildVariant

ClientBuild::VariantId Battlenet::Session::_buildVariant
private

Definition at line 164 of file Session.h.

Referenced by GetBuildVariant().

◆ _clientInstanceId

std::string Battlenet::Session::_clientInstanceId
private

Definition at line 156 of file Session.h.

Referenced by SetClientInstanceId().

◆ _clientSecret

std::array<uint8, 32> Battlenet::Session::_clientSecret
private

Definition at line 169 of file Session.h.

Referenced by GetClientSecret().

◆ _creationTime

SystemTimePoint const Battlenet::Session::_creationTime
private

Definition at line 155 of file Session.h.

Referenced by GetCreationTime().

◆ _gameAccountInfo

GameAccountInfo const* Battlenet::Session::_gameAccountInfo
private

Definition at line 159 of file Session.h.

Referenced by GetGameAccountId(), and GetGameAccountInfo().

◆ _ipCountry

std::string Battlenet::Session::_ipCountry
private

Definition at line 167 of file Session.h.

◆ _locale

std::string Battlenet::Session::_locale
private

Definition at line 161 of file Session.h.

Referenced by GetLocale().

◆ _os

std::string Battlenet::Session::_os
private

Definition at line 162 of file Session.h.

Referenced by GetOS().

◆ _packetBuffer

MessageBuffer Battlenet::Session::_packetBuffer
private

Definition at line 152 of file Session.h.

◆ _packetReadState

PacketReadState Battlenet::Session::_packetReadState
private

Definition at line 151 of file Session.h.

◆ _queryProcessor

QueryCallbackProcessor Battlenet::Session::_queryProcessor
private

Definition at line 173 of file Session.h.

◆ _requestToken

uint32 Battlenet::Session::_requestToken
private

Definition at line 176 of file Session.h.

◆ _responseCallbacks

std::unordered_map<uint32, std::function<void(MessageBuffer)> > Battlenet::Session::_responseCallbacks
private

Definition at line 175 of file Session.h.

◆ _sessionId

uint32 const Battlenet::Session::_sessionId
private

Definition at line 154 of file Session.h.

Referenced by GetSessionId().

◆ _socket

std::shared_ptr<Socket> Battlenet::Session::_socket
private

Definition at line 142 of file Session.h.

Referenced by CloseSocket(), DelayedCloseSocket(), GetRemoteIpAddress(), and IsOpen().

◆ _timezoneOffset

Minutes Battlenet::Session::_timezoneOffset
private

Definition at line 165 of file Session.h.

Referenced by GetTimezoneOffset().


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