TrinityCore
Loading...
Searching...
No Matches
GameUtilitiesService.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 TRINITYCORE_GAME_UTILITIES_SERVICE_H
19#define TRINITYCORE_GAME_UTILITIES_SERVICE_H
20
21#include "Service.h"
22#include "Client/game_utilities_service.pb.h"
23#include "Client/api/client/v2/game_utilities_service.pb.h"
24#include <variant>
25#include <vector>
26
27namespace Battlenet::Services
28{
29 using Variant = std::variant<bool, int64, double, std::string, std::vector<uint8>, uint64>;
30
31 namespace Shared
32 {
34 {
35 public:
36 static std::string_view ParseParamName(std::string_view command);
37 static Variant* FindParamValue(std::vector<std::pair<std::string_view, Variant>>& params, std::string_view paramName);
38 static std::vector<uint8> CompressJson(std::string const& json);
39
40 static uint32 HandleClientRequest(Session* session,
41 std::vector<std::pair<std::string_view, Variant>>& params,
42 std::vector<std::pair<std::string_view, Variant>>& responseValues);
43
44 static uint32 HandleGetAllValuesForAttribute(Session const* session, std::string_view command, std::vector<Variant>& responseValues);
45
46 private:
47 static uint32 GetLastCharPlayed(Session const* session, std::vector<std::pair<std::string_view, Variant>>& params,
48 std::vector<std::pair<std::string_view, Variant>>& responseValues);
49 static uint32 GetRealmListTicket(Session* session, std::vector<std::pair<std::string_view, Variant>>& params,
50 std::vector<std::pair<std::string_view, Variant>>& responseValues);
51 static uint32 GetRealmList(Session const* session, std::vector<std::pair<std::string_view, Variant>>& params,
52 std::vector<std::pair<std::string_view, Variant>>& responseValues);
53 static uint32 JoinRealm(Session const* session, std::vector<std::pair<std::string_view, Variant>>& params,
54 std::vector<std::pair<std::string_view, Variant>>& responseValues);
55 static uint32 GetBleepProxies(Session const* session, std::vector<std::pair<std::string_view, Variant>>& params,
56 std::vector<std::pair<std::string_view, Variant>>& responseValues);
57 };
58 }
59
60 namespace V1
61 {
62 Battlenet::Services::Variant FromProto(bgs::protocol::Variant const& from);
63 void ToProto(Battlenet::Services::Variant const& from, bgs::protocol::Variant* to);
64
65 class GameUtilities : public Service<game_utilities::v1::GameUtilitiesService>
66 {
68
69 public:
70 GameUtilities(Session* session);
71
72 uint32 HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation) override;
73 uint32 HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const* request, game_utilities::v1::GetAllValuesForAttributeResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation) override;
74 };
75 }
76
77 namespace V2
78 {
79 Battlenet::Services::Variant FromProto(bgs::protocol::v2::Variant const& from);
80 void ToProto(Battlenet::Services::Variant const& from, bgs::protocol::v2::Variant* to);
81
82 class GameUtilities : public Service<game_utilities::v2::client::GameUtilitiesService>
83 {
85
86 public:
87 GameUtilities(Session* session);
88
89 uint32 HandleProcessTask(game_utilities::v2::client::ProcessTaskRequest const* request, game_utilities::v2::client::ProcessTaskResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation) override;
90 uint32 HandleGetAllValuesForAttribute(game_utilities::v2::client::GetAllValuesForAttributeRequest const* request, game_utilities::v2::client::GetAllValuesForAttributeResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation) override;
91 };
92 }
93}
94
95#endif // TRINITYCORE_GAME_UTILITIES_SERVICE_H
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
std::unordered_set< uint32 > params[2]
static uint32 GetLastCharPlayed(Session const *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static Variant * FindParamValue(std::vector< std::pair< std::string_view, Variant > > &params, std::string_view paramName)
static uint32 HandleClientRequest(Session *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static std::string_view ParseParamName(std::string_view command)
static uint32 JoinRealm(Session const *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static uint32 GetRealmList(Session const *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static uint32 GetBleepProxies(Session const *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static uint32 HandleGetAllValuesForAttribute(Session const *session, std::string_view command, std::vector< Variant > &responseValues)
static uint32 GetRealmListTicket(Session *session, std::vector< std::pair< std::string_view, Variant > > &params, std::vector< std::pair< std::string_view, Variant > > &responseValues)
static std::vector< uint8 > CompressJson(std::string const &json)
Service< game_utilities::v1::GameUtilitiesService > GameUtilitiesService
uint32 HandleProcessClientRequest(game_utilities::v1::ClientRequest const *request, game_utilities::v1::ClientResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const *request, game_utilities::v1::GetAllValuesForAttributeResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleProcessTask(game_utilities::v2::client::ProcessTaskRequest const *request, game_utilities::v2::client::ProcessTaskResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
uint32 HandleGetAllValuesForAttribute(game_utilities::v2::client::GetAllValuesForAttributeRequest const *request, game_utilities::v2::client::GetAllValuesForAttributeResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
Service< game_utilities::v2::client::GameUtilitiesService > GameUtilitiesService
Battlenet::Services::Variant FromProto(bgs::protocol::Variant const &from)
void ToProto(Battlenet::Services::Variant const &from, bgs::protocol::Variant *to)
Battlenet::Services::Variant FromProto(bgs::protocol::v2::Variant const &from)
void ToProto(Battlenet::Services::Variant const &from, bgs::protocol::v2::Variant *to)
std::variant< bool, int64, double, std::string, std::vector< uint8 >, uint64 > Variant