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"
32#include "friends_service.pb.h"
34#include "presence_service.pb.h"
35#include "report_service.pb.h"
36#include "resource_service.pb.h"
37
39{
40 AddService<Services::Account>();
41 AddService<Services::Authentication>();
42 AddService<Service<block_list::v1::client::BlockListService>>();
43 AddService<Service<club_membership::v1::client::ClubMembershipService>>();
44 AddService<Service<club::v1::client::ClubService>>();
45 AddService<Services::Connection>();
46 AddService<Service<friends::v1::FriendsService>>();
47 AddService<Services::GameUtilities>();
48 AddService<Service<notification::v1::NotificationService>>();
49 AddService<Service<notification::v2::client::NotificationService>>();
50 AddService<Service<presence::v1::PresenceService>>();
51 AddService<Service<report::v1::ReportService>>();
52 AddService<Service<report::v2::ReportService>>();
53 AddService<Service<resources::v1::ResourcesService>>();
54 AddService<Service<whisper::v2::client::WhisperService>>();
55}
56
57void Battlenet::ServiceDispatcher::Dispatch(Session* session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
58{
59 auto itr = _dispatchers.find(serviceHash);
60 if (itr != _dispatchers.end())
61 itr->second(session, token, methodId, std::move(buffer));
62 else
63 TC_LOG_DEBUG("session.rpc", "{} tried to call invalid service 0x{:X}", session->GetClientInfo(), serviceHash);
64}
65
uint32_t uint32
Definition Define.h:154
#define TC_LOG_DEBUG(filterType__, message__,...)
Definition Log.h:181
void Dispatch(Session *session, uint32 serviceHash, uint32 token, uint32 methodId, MessageBuffer buffer)
static ServiceDispatcher & Instance()
std::string GetClientInfo() const
Definition Session.cpp:806