TrinityCore
Loading...
Searching...
No Matches
WorldserverGameUtilitiesService.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 WORLDSERVER_GAME_UTILITIES_SERVICE_H
19#define WORLDSERVER_GAME_UTILITIES_SERVICE_H
20
21#include "WorldserverService.h"
22#include "Client/game_utilities_service.pb.h"
23#include "Client/api/client/v2/game_utilities_service.pb.h"
24
25namespace Battlenet::Services
26{
27 using Variant = std::variant<bool, int64, double, std::string, std::vector<uint8>, uint64>;
28
29 namespace Shared
30 {
31 class GameUtilities
32 {
33 public:
34 static std::string_view ParseParamName(std::string_view command);
35 static Variant* FindParamValue(std::vector<std::pair<std::string_view, Variant>>& params, std::string_view paramName);
36
37 static uint32 HandleClientRequest(WorldSession const* session,
38 std::vector<std::pair<std::string_view, Variant>>& params,
39 std::vector<std::pair<std::string_view, Variant>>& responseValues);
40
41 static uint32 HandleGetAllValuesForAttribute(WorldSession const* session, std::string_view command, std::vector<Variant>& responseValues);
42
43 private:
44 static uint32 GetRealmList(WorldSession const* session, std::vector<std::pair<std::string_view, Variant>>& params,
45 std::vector<std::pair<std::string_view, Variant>>& responseValues);
46 static uint32 JoinRealm(WorldSession const* session, std::vector<std::pair<std::string_view, Variant>>& params,
47 std::vector<std::pair<std::string_view, Variant>>& responseValues);
48 };
49 }
50
51 namespace V2
52 {
53 Battlenet::Services::Variant FromProto(bgs::protocol::v2::Variant const& from);
54 void ToProto(Battlenet::Services::Variant const& from, bgs::protocol::v2::Variant* to);
55
56 class GameUtilitiesService : public WorldserverService<game_utilities::v2::client::GameUtilitiesService>
57 {
59
60 public:
62
63 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;
64 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;
65 };
66 }
67
69}
70
71#endif // WORLDSERVER_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 std::string_view ParseParamName(std::string_view command)
static uint32 HandleClientRequest(Session *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 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 HandleGetAllValuesForAttribute(Session const *session, std::string_view command, std::vector< Variant > &responseValues)
WorldserverService< game_utilities::v2::client::GameUtilitiesService > BaseService
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
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
Player session in the World.
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