TrinityCore
WorldserverServiceDispatcher.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef WorldserverServiceDispatcher_h__
19#define WorldserverServiceDispatcher_h__
20
21#include "WorldSession.h"
22#include "MessageBuffer.h"
23#include "Log.h"
24#include "account_service.pb.h"
27#include "club_listener.pb.h"
30#include "ClubService.h"
32#include "friends_service.pb.h"
35#include "presence_service.pb.h"
36#include "report_service.pb.h"
38#include "resource_service.pb.h"
40
41namespace Battlenet
42{
44 {
45 public:
46 void Dispatch(WorldSession* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer);
47
49
50 private:
52
53 template<class Service>
55 {
56 _dispatchers[Service::OriginalHash::value] = &WorldserverServiceDispatcher::Dispatch<Service>;
57 }
58
59 template<class Service>
60 static void Dispatch(WorldSession* session, uint32 token, uint32 methodId, MessageBuffer buffer)
61 {
62 Service(session).CallServerMethod(token, methodId, std::move(buffer));
63 }
64
66 std::unordered_map<uint32, ServiceMethod> _dispatchers;
67 };
68}
69
70#define sServiceDispatcher Battlenet::WorldserverServiceDispatcher::Instance()
71
72#endif // WorldserverServiceDispatcher_h__
uint32_t uint32
Definition: Define.h:142
void(* ServiceMethod)(WorldSession *, uint32, uint32, MessageBuffer)
void Dispatch(WorldSession *session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
std::unordered_map< uint32, ServiceMethod > _dispatchers
static WorldserverServiceDispatcher & Instance()
static void Dispatch(WorldSession *session, uint32 token, uint32 methodId, MessageBuffer buffer)
Player session in the World.
Definition: WorldSession.h:963