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

#include <WorldserverServiceDispatcher.h>

Public Member Functions

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

Static Public Member Functions

static
WorldserverServiceDispatcher
Instance ()
 

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

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

Constructor & Destructor Documentation

Battlenet::WorldserverServiceDispatcher::WorldserverServiceDispatcher ( )
private
22 {
23  AddService<WorldserverService<account::v1::AccountService>>();
24  AddService<WorldserverService<authentication::v1::AuthenticationService>>();
25  AddService<WorldserverService<challenge::v1::ChallengeService>>();
26  AddService<WorldserverService<channel::v1::ChannelService>>();
27  AddService<WorldserverService<connection::v1::ConnectionService>>();
28  AddService<WorldserverService<friends::v1::FriendsService>>();
29  AddService<GameUtilitiesService>();
30  AddService<WorldserverService<presence::v1::PresenceService>>();
31  AddService<WorldserverService<report::v1::ReportService>>();
32  AddService<WorldserverService<resources::v1::ResourcesService>>();
33  AddService<WorldserverService<user_manager::v1::UserManagerService>>();
34 }

Member Function Documentation

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

+ Here is the call graph for this function:

template<class Service >
static void Battlenet::WorldserverServiceDispatcher::Dispatch ( WorldSession session,
uint32  token,
uint32  methodId,
MessageBuffer  buffer 
)
inlinestaticprivate
57  {
58  Service(session).CallServerMethod(token, methodId, std::forward<MessageBuffer>(buffer));
59  }
Battlenet::WorldserverServiceDispatcher & Battlenet::WorldserverServiceDispatcher::Instance ( )
static
46 {
47  static WorldserverServiceDispatcher instance;
48  return instance;
49 }
WorldserverServiceDispatcher()
Definition: WorldserverServiceDispatcher.cpp:21

Member Data Documentation

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

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