TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Battlenet::ServiceDispatcher Class Reference

#include <ServiceDispatcher.h>

Public Member Functions

void Dispatch (Session *session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
 

Static Public Member Functions

static ServiceDispatcherInstance ()
 

Private Member Functions

 ServiceDispatcher ()
 
template<class Service >
void AddService ()
 

Static Private Member Functions

template<class Service >
static void Dispatch (Session *session, uint32 token, uint32 methodId, MessageBuffer buffer)
 

Private Attributes

std::unordered_map< uint32,
std::function< void(Session
*, uint32, uint32,
MessageBuffer)> > 
_dispatchers
 

Constructor & Destructor Documentation

Battlenet::ServiceDispatcher::ServiceDispatcher ( )
private
21 {
22  AddService<Services::Account>();
23  AddService<Services::Authentication>();
24  AddService<Service<challenge::v1::ChallengeService>>();
25  AddService<Service<channel::v1::ChannelService>>();
26  AddService<Services::Connection>();
27  AddService<Service<friends::v1::FriendsService>>();
28  AddService<Services::GameUtilities>();
29  AddService<Service<presence::v1::PresenceService>>();
30  AddService<Service<report::v1::ReportService>>();
31  AddService<Service<resources::v1::ResourcesService>>();
32  AddService<Service<user_manager::v1::UserManagerService>>();
33 }

Member Function Documentation

template<class Service >
void Battlenet::ServiceDispatcher::AddService ( )
inlineprivate
52  {
53  _dispatchers[Service::OriginalHash::value] = &ServiceDispatcher::Dispatch<Service>;
54  }
std::unordered_map< uint32, std::function< void(Session *, uint32, uint32, MessageBuffer)> > _dispatchers
Definition: ServiceDispatcher.h:62
const FieldDescriptor value
Definition: descriptor.h:1522
void Battlenet::ServiceDispatcher::Dispatch ( Session session,
uint32  serviceHash,
uint32  token,
uint32  methodId,
MessageBuffer  buffer 
)
36 {
37  auto itr = _dispatchers.find(serviceHash);
38  if (itr != _dispatchers.end())
39  itr->second(session, token, methodId, std::forward<MessageBuffer>(buffer));
40  else
41  TC_LOG_DEBUG("session.rpc", "%s tried to call invalid service 0x%X", session->GetClientInfo().c_str(), serviceHash);
42 }
std::unordered_map< uint32, std::function< void(Session *, uint32, uint32, MessageBuffer)> > _dispatchers
Definition: ServiceDispatcher.h:62
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198

+ Here is the call graph for this function:

template<class Service >
static void Battlenet::ServiceDispatcher::Dispatch ( Session session,
uint32  token,
uint32  methodId,
MessageBuffer  buffer 
)
inlinestaticprivate
58  {
59  Service(session).CallServerMethod(token, methodId, std::forward<MessageBuffer>(buffer));
60  }
Battlenet::ServiceDispatcher & Battlenet::ServiceDispatcher::Instance ( )
static
45 {
46  static ServiceDispatcher instance;
47  return instance;
48 }
ServiceDispatcher()
Definition: ServiceDispatcher.cpp:20

Member Data Documentation

std::unordered_map<uint32, std::function<void(Session*, uint32, uint32, MessageBuffer)> > Battlenet::ServiceDispatcher::_dispatchers
private

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