TrinityCore
Battlenet::Session Class Reference

#include <Session.h>

+ Inheritance diagram for Battlenet::Session:

Classes

struct  AccountInfo
 
struct  GameAccountInfo
 
struct  LastPlayedCharacterInfo
 

Public Member Functions

 Session (boost::asio::ip::tcp::socket &&socket)
 
 ~Session ()
 
void Start () override
 
bool Update () override
 
uint32 GetAccountId () const
 
uint32 GetGameAccountId () 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)
 
uint32 HandleLogon (authentication::v1::LogonRequest const *logonRequest, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation)
 
uint32 HandleVerifyWebCredentials (authentication::v1::VerifyWebCredentialsRequest const *verifyWebCredentialsRequest, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation)
 
uint32 HandleGenerateWebCredentials (authentication::v1::GenerateWebCredentialsRequest const *request, std::function< void(ServiceBase *, uint32, google::protobuf::Message const *)> &continuation)
 
uint32 HandleGetAccountState (account::v1::GetAccountStateRequest const *request, account::v1::GetAccountStateResponse *response)
 
uint32 HandleGetGameAccountState (account::v1::GetGameAccountStateRequest const *request, account::v1::GetGameAccountStateResponse *response)
 
uint32 HandleProcessClientRequest (game_utilities::v1::ClientRequest const *request, game_utilities::v1::ClientResponse *response)
 
uint32 HandleGetAllValuesForAttribute (game_utilities::v1::GetAllValuesForAttributeRequest const *request, game_utilities::v1::GetAllValuesForAttributeResponse *response)
 
std::string GetClientInfo () const
 
- Public Member Functions inherited from Socket< Session, SslSocket<> >
 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 Member Functions

void HandshakeHandler (boost::system::error_code const &error)
 
void ReadHandler () override
 
bool ReadHeaderLengthHandler ()
 
bool ReadHeaderHandler ()
 
bool ReadDataHandler ()
 
- Protected Member Functions inherited from Socket< Session, SslSocket<> >
virtual void OnClose ()
 
virtual void ReadHandler ()=0
 
bool AsyncProcessQueue ()
 
void SetNoDelay (bool enable)
 
SslSocket<> & underlying_stream ()
 

Private Types

typedef Socket< Session, SslSocket<> > BattlenetSocket
 
typedef uint32(Session::* ClientRequestHandler) (std::unordered_map< std::string, Variant const * > const &, game_utilities::v1::ClientResponse *)
 

Private Member Functions

void AsyncWrite (MessageBuffer *packet)
 
void AsyncHandshake ()
 
void CheckIpCallback (PreparedQueryResult result)
 
uint32 VerifyWebCredentials (std::string const &webCredentials, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation)
 
uint32 GetRealmListTicket (std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
 
uint32 GetLastCharPlayed (std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
 
uint32 GetRealmList (std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
 
uint32 JoinRealm (std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
 

Private Attributes

MessageBuffer _headerLengthBuffer
 
MessageBuffer _headerBuffer
 
MessageBuffer _packetBuffer
 
std::shared_ptr< AccountInfo_accountInfo
 
GameAccountInfo_gameAccountInfo
 
std::string _locale
 
std::string _os
 
uint32 _build
 
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
 

Static Private Attributes

static std::unordered_map< std::string, ClientRequestHandler > const ClientRequestHandlers
 

Detailed Description

Definition at line 67 of file Session.h.

Member Typedef Documentation

◆ BattlenetSocket

Definition at line 69 of file Session.h.

◆ ClientRequestHandler

typedef uint32(Session::* Battlenet::Session::ClientRequestHandler) (std::unordered_map< std::string, Variant const * > const &, game_utilities::v1::ClientResponse *)
private

Definition at line 158 of file Session.h.

Constructor & Destructor Documentation

◆ Session()

Battlenet::Session::Session ( boost::asio::ip::tcp::socket &&  socket)
explicit

Definition at line 77 of file Session.cpp.

+ Here is the call graph for this function:

◆ ~Session()

Battlenet::Session::~Session ( )
default

Member Function Documentation

◆ AsyncHandshake()

void Battlenet::Session::AsyncHandshake ( )
private

Definition at line 86 of file Session.cpp.

◆ AsyncWrite()

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

Definition at line 141 of file Session.cpp.

◆ CheckIpCallback()

void Battlenet::Session::CheckIpCallback ( PreparedQueryResult  result)
private

Definition at line 107 of file Session.cpp.

◆ GetAccountId()

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

Definition at line 118 of file Session.h.

◆ GetClientInfo()

std::string Battlenet::Session::GetClientInfo ( ) const

Definition at line 829 of file Session.cpp.

+ Here is the caller graph for this function:

◆ GetGameAccountId()

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

Definition at line 119 of file Session.h.

◆ GetLastCharPlayed()

uint32 Battlenet::Session::GetLastCharPlayed ( std::unordered_map< std::string, Variant const * > const &  params,
game_utilities::v1::ClientResponse *  response 
)
private

Definition at line 620 of file Session.cpp.

+ Here is the call graph for this function:

◆ GetRealmList()

uint32 Battlenet::Session::GetRealmList ( std::unordered_map< std::string, Variant const * > const &  params,
game_utilities::v1::ClientResponse *  response 
)
private

Definition at line 655 of file Session.cpp.

+ Here is the call graph for this function:

◆ GetRealmListTicket()

uint32 Battlenet::Session::GetRealmListTicket ( std::unordered_map< std::string, Variant const * > const &  params,
game_utilities::v1::ClientResponse *  response 
)
private

Definition at line 565 of file Session.cpp.

+ Here is the call graph for this function:

◆ HandleGenerateWebCredentials()

uint32 Battlenet::Session::HandleGenerateWebCredentials ( authentication::v1::GenerateWebCredentialsRequest const *  request,
std::function< void(ServiceBase *, uint32, google::protobuf::Message const *)> &  continuation 
)

Definition at line 276 of file Session.cpp.

+ Here is the call graph for this function:

◆ HandleGetAccountState()

uint32 Battlenet::Session::HandleGetAccountState ( account::v1::GetAccountStateRequest const *  request,
account::v1::GetAccountStateResponse *  response 
)

Definition at line 456 of file Session.cpp.

◆ HandleGetAllValuesForAttribute()

uint32 Battlenet::Session::HandleGetAllValuesForAttribute ( game_utilities::v1::GetAllValuesForAttributeRequest const *  request,
game_utilities::v1::GetAllValuesForAttributeResponse *  response 
)

Definition at line 705 of file Session.cpp.

◆ HandleGetGameAccountState()

uint32 Battlenet::Session::HandleGetGameAccountState ( account::v1::GetGameAccountStateRequest const *  request,
account::v1::GetGameAccountStateResponse *  response 
)

Definition at line 473 of file Session.cpp.

◆ HandleLogon()

uint32 Battlenet::Session::HandleLogon ( authentication::v1::LogonRequest const *  logonRequest,
std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &  continuation 
)

Definition at line 214 of file Session.cpp.

+ Here is the call graph for this function:

◆ HandleProcessClientRequest()

uint32 Battlenet::Session::HandleProcessClientRequest ( game_utilities::v1::ClientRequest const *  request,
game_utilities::v1::ClientResponse *  response 
)

Definition at line 515 of file Session.cpp.

+ Here is the call graph for this function:

◆ HandleVerifyWebCredentials()

uint32 Battlenet::Session::HandleVerifyWebCredentials ( authentication::v1::VerifyWebCredentialsRequest const *  verifyWebCredentialsRequest,
std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &  continuation 
)

Definition at line 268 of file Session.cpp.

◆ HandshakeHandler()

void Battlenet::Session::HandshakeHandler ( boost::system::error_code const &  error)
protected

Definition at line 719 of file Session.cpp.

◆ JoinRealm()

uint32 Battlenet::Session::JoinRealm ( std::unordered_map< std::string, Variant const * > const &  params,
game_utilities::v1::ClientResponse *  response 
)
private

Definition at line 696 of file Session.cpp.

+ Here is the call graph for this function:

◆ ReadDataHandler()

bool Battlenet::Session::ReadDataHandler ( )
protected

Definition at line 804 of file Session.cpp.

+ Here is the call graph for this function:

◆ ReadHandler()

void Battlenet::Session::ReadHandler ( )
overrideprotectedvirtual

Implements Socket< Session, SslSocket<> >.

Definition at line 762 of file Session.cpp.

+ Here is the call graph for this function:

◆ ReadHeaderHandler()

bool Battlenet::Session::ReadHeaderHandler ( )
protected

Definition at line 794 of file Session.cpp.

+ Here is the call graph for this function:

◆ ReadHeaderLengthHandler()

bool Battlenet::Session::ReadHeaderLengthHandler ( )
protected

Definition at line 786 of file Session.cpp.

+ Here is the call graph for this function:

◆ SendRequest() [1/2]

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

Definition at line 190 of file Session.cpp.

+ Here is the call graph for this function:

◆ SendRequest() [2/2]

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

Definition at line 124 of file Session.h.

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

◆ SendResponse() [1/2]

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

Definition at line 149 of file Session.cpp.

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

◆ SendResponse() [2/2]

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

Definition at line 171 of file Session.cpp.

+ Here is the call graph for this function:

◆ Start()

void Battlenet::Session::Start ( )
overridevirtual

Implements Socket< Session, SslSocket<> >.

Definition at line 92 of file Session.cpp.

+ Here is the call graph for this function:

◆ Update()

bool Battlenet::Session::Update ( )
overridevirtual

Reimplemented from Socket< Session, SslSocket<> >.

Definition at line 131 of file Session.cpp.

+ Here is the call graph for this function:

◆ VerifyWebCredentials()

uint32 Battlenet::Session::VerifyWebCredentials ( std::string const &  webCredentials,
std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &  continuation 
)
private

Definition at line 306 of file Session.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ _accountInfo

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

Definition at line 170 of file Session.h.

◆ _authed

bool Battlenet::Session::_authed
private

Definition at line 182 of file Session.h.

◆ _build

uint32 Battlenet::Session::_build
private

Definition at line 175 of file Session.h.

◆ _clientSecret

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

Definition at line 180 of file Session.h.

◆ _gameAccountInfo

GameAccountInfo* Battlenet::Session::_gameAccountInfo
private

Definition at line 171 of file Session.h.

◆ _headerBuffer

MessageBuffer Battlenet::Session::_headerBuffer
private

Definition at line 167 of file Session.h.

◆ _headerLengthBuffer

MessageBuffer Battlenet::Session::_headerLengthBuffer
private

Definition at line 166 of file Session.h.

◆ _ipCountry

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

Definition at line 178 of file Session.h.

◆ _locale

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

Definition at line 173 of file Session.h.

◆ _os

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

Definition at line 174 of file Session.h.

◆ _packetBuffer

MessageBuffer Battlenet::Session::_packetBuffer
private

Definition at line 168 of file Session.h.

◆ _queryProcessor

QueryCallbackProcessor Battlenet::Session::_queryProcessor
private

Definition at line 184 of file Session.h.

◆ _requestToken

uint32 Battlenet::Session::_requestToken
private

Definition at line 187 of file Session.h.

◆ _responseCallbacks

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

Definition at line 186 of file Session.h.

◆ _timezoneOffset

Minutes Battlenet::Session::_timezoneOffset
private

Definition at line 176 of file Session.h.

◆ ClientRequestHandlers

std::unordered_map< std::string, Battlenet::Session::ClientRequestHandler > const Battlenet::Session::ClientRequestHandlers
staticprivate
Initial value:
=
{
{ "Command_RealmListTicketRequest_v1", &Battlenet::Session::GetRealmListTicket },
{ "Command_LastCharPlayedRequest_v1", &Battlenet::Session::GetLastCharPlayed },
{ "Command_RealmListRequest_v1", &Battlenet::Session::GetRealmList },
{ "Command_RealmJoinRequest_v1", &Battlenet::Session::JoinRealm },
}
uint32 JoinRealm(std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
Definition: Session.cpp:696
uint32 GetRealmList(std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
Definition: Session.cpp:655
uint32 GetLastCharPlayed(std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
Definition: Session.cpp:620
uint32 GetRealmListTicket(std::unordered_map< std::string, Variant const * > const &params, game_utilities::v1::ClientResponse *response)
Definition: Session.cpp:565

Definition at line 159 of file Session.h.


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