TrinityCore
Loading...
Searching...
No Matches
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"
32#include "ClubService.h"
34#include "friends_service.pb.h"
40#include "presence_service.pb.h"
41#include "report_service.pb.h"
43#include "resource_service.pb.h"
46
47namespace Battlenet
48{
50 {
51 public:
52 void Dispatch(WorldSession* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer);
53
55
56 private:
58
59 template<class Service>
61 {
62 _dispatchers[Service::OriginalHash::value] = &WorldserverServiceDispatcher::Dispatch<Service>;
63 }
64
65 template<class Service>
66 static void Dispatch(WorldSession* session, uint32 token, uint32 methodId, MessageBuffer buffer)
67 {
68 Service(session).CallServerMethod(token, methodId, std::move(buffer));
69 }
70
72 std::unordered_map<uint32, ServiceMethod> _dispatchers;
73 };
74}
75
76#define sServiceDispatcher Battlenet::WorldserverServiceDispatcher::Instance()
77
78#endif // WorldserverServiceDispatcher_h__
uint32_t uint32
Definition Define.h:154
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.