TrinityCore
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
21{
22 AddService<Services::Account>();
23 AddService<Services::Authentication>();
24 AddService<Service<club::v1::membership::ClubMembershipService>>();
25 AddService<Service<club::v1::ClubService>>();
26 AddService<Services::Connection>();
27 AddService<Service<friends::v1::FriendsService>>();
28 AddService<Services::GameUtilities>();
29 AddService<Service<presence::v1::PresenceService>>();
30 AddService<Service<report::v1::ReportService>>();
31 AddService<Service<report::v2::ReportService>>();
32 AddService<Service<resources::v1::ResourcesService>>();
33 AddService<Service<user_manager::v1::UserManagerService>>();
34}
35
36void Battlenet::ServiceDispatcher::Dispatch(Session* 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::move(buffer));
41 else
42 TC_LOG_DEBUG("session.rpc", "{} tried to call invalid service 0x{:X}", session->GetClientInfo(), serviceHash);
43}
44
46{
47 static ServiceDispatcher instance;
48 return instance;
49}
uint32_t uint32
Definition: Define.h:142
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:156
void Dispatch(Session *session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
static ServiceDispatcher & Instance()
std::string GetClientInfo() const
Definition: Session.cpp:829