TrinityCore
Loading...
Searching...
No Matches
ServiceDispatcher.cpp
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#include "ServiceDispatcher.h"
19#include "AccountService.h"
21#include "ConnectionService.h"
23#include "Log.h"
24#include "Session.h"
25#include "Client/api/client/v1/block_list_listener.pb.h"
26#include "Client/api/client/v1/block_list_service.pb.h"
27#include "Client/api/client/v1/club_membership_service.pb.h"
28#include "Client/api/client/v1/club_service.pb.h"
29#include "Client/api/client/v2/friends_service.pb.h"
30#include "Client/api/client/v2/notification_service.pb.h"
31#include "Client/api/client/v2/presence_service.pb.h"
32#include "Client/api/client/v2/report_service.pb.h"
33#include "Client/api/client/v2/whisper_service.pb.h"
34#include "Client/api/client/v3/report_service.pb.h"
35#include "Client/friends_service.pb.h"
36#include "Client/notification_service.pb.h"
37#include "Client/presence_service.pb.h"
38#include "Client/report_service.pb.h"
39#include "Client/resource_service.pb.h"
40
42{
43 AddService<Services::V1::Account>();
44 AddService<Services::V2::Account>();
45 AddService<Services::V1::Authentication>();
46 AddService<Services::V2::Authentication>();
47 AddService<Service<block_list::v1::client::BlockListService>>();
48 AddService<Service<club_membership::v1::client::ClubMembershipService>>();
49 AddService<Service<club::v1::client::ClubService>>();
50 AddService<Services::V1::Connection>();
51 AddService<Service<friends::v1::FriendsService>>();
52 AddService<Service<friends::v2::client::FriendsService>>();
53 AddService<Services::V1::GameUtilities>();
54 AddService<Services::V2::GameUtilities>();
55 AddService<Service<notification::v1::NotificationService>>();
56 AddService<Service<notification::v2::client::NotificationService>>();
57 AddService<Service<presence::v1::PresenceService>>();
58 AddService<Service<presence::v2::client::PresenceService>>();
59 AddService<Service<report::v1::ReportService>>();
60 AddService<Service<report::v2::ReportService>>();
61 AddService<Service<report::v3::client::ReportService>>();
62 AddService<Service<resources::v1::ResourcesService>>();
63 AddService<Service<whisper::v2::client::WhisperService>>();
64}
65
66void Battlenet::ServiceDispatcher::Dispatch(Session* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
67{
68 auto itr = _dispatchers.find(serviceHash);
69 if (itr != _dispatchers.end())
70 itr->second(session, token, methodId, std::move(buffer));
71 else
72 TC_LOG_DEBUG("session.rpc", "{} tried to call invalid service 0x{:X}", session->GetClientInfo(), serviceHash);
73}
74
uint32_t uint32
Definition Define.h:154
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:173
void Dispatch(Session *session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
static ServiceDispatcher & Instance()
std::string GetClientInfo() const
Definition Session.cpp:345