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 "Client/account_service.pb.h"
25#include "Client/api/client/v2/account_service.pb.h"
26#include "Client/authentication_service.pb.h"
27#include "Client/api/client/v2/authentication_service.pb.h"
28#include "Client/api/client/v1/block_list_listener.pb.h"
29#include "Client/api/client/v1/block_list_service.pb.h"
30#include "Client/challenge_service.pb.h"
31#include "Client/api/client/v1/club_listener.pb.h"
32#include "Client/api/client/v1/club_membership_listener.pb.h"
34#include "ClubService.h"
35#include "Client/connection_service.pb.h"
36#include "Client/friends_service.pb.h"
37#include "Client/api/client/v2/friends_service.pb.h"
39#include "Client/notification_service.pb.h"
40#include "Client/api/client/v2/notification_listener.pb.h"
41#include "Client/api/client/v2/notification_service.pb.h"
42#include "Client/presence_listener.pb.h"
43#include "Client/presence_service.pb.h"
44#include "Client/api/client/v2/presence_service.pb.h"
45#include "Client/report_service.pb.h"
46#include "Client/api/client/v2/report_service.pb.h"
47#include "Client/api/client/v3/report_service.pb.h"
48#include "Client/resource_service.pb.h"
49#include "Client/api/client/v2/whisper_listener.pb.h"
50#include "Client/api/client/v2/whisper_service.pb.h"
51
52namespace Battlenet
53{
55 {
56 public:
57 void Dispatch(WorldSession* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer);
58
60
61 private:
63
64 template<class Service>
66 {
67 _dispatchers[Service::OriginalHash::value] = &WorldserverServiceDispatcher::Dispatch<Service>;
68 }
69
70 template<class Service>
71 static void Dispatch(WorldSession* session, uint32 token, uint32 methodId, MessageBuffer buffer)
72 {
73 Service(session).CallServerMethod(token, methodId, std::move(buffer));
74 }
75
77 std::unordered_map<uint32, ServiceMethod> _dispatchers;
78 };
79}
80
81#define sServiceDispatcher Battlenet::WorldserverServiceDispatcher::Instance()
82
83#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.