TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Battlenet::GameUtilitiesService Class Reference

#include <WorldserverService.h>

Public Member Functions

 GameUtilitiesService (WorldSession *session)
 
uint32 HandleProcessClientRequest (game_utilities::v1::ClientRequest const *request, game_utilities::v1::ClientResponse *response) override
 
uint32 HandleGetAllValuesForAttribute (game_utilities::v1::GetAllValuesForAttributeRequest const *request, game_utilities::v1::GetAllValuesForAttributeResponse *response) override
 
- Public Member Functions inherited from Battlenet::WorldserverService< game_utilities::v1::GameUtilitiesService >
 WorldserverService (WorldSession *session)
 

Private Types

typedef WorldserverService
< game_utilities::v1::GameUtilitiesService
BaseService
 

Private Member Functions

uint32 HandleRealmListRequest (std::unordered_map< std::string, Variant const * > params, game_utilities::v1::ClientResponse *response)
 
uint32 HandleRealmJoinRequest (std::unordered_map< std::string, Variant const * > params, game_utilities::v1::ClientResponse *response)
 

Additional Inherited Members

- Protected Member Functions inherited from Battlenet::WorldserverService< game_utilities::v1::GameUtilitiesService >
void SendRequest (uint32 serviceHash, uint32 methodId, google::protobuf::Message const *request, std::function< void(MessageBuffer)> callback) override
 
void SendRequest (uint32 serviceHash, uint32 methodId, google::protobuf::Message const *request) override
 
void SendResponse (uint32 serviceHash, uint32 methodId, uint32 token, uint32 status) override
 
void SendResponse (uint32 serviceHash, uint32 methodId, uint32 token, google::protobuf::Message const *response) override
 
std::string GetCallerInfo () const override
 
- Protected Attributes inherited from Battlenet::WorldserverService< game_utilities::v1::GameUtilitiesService >
WorldSession_session
 

Member Typedef Documentation

Constructor & Destructor Documentation

Battlenet::GameUtilitiesService::GameUtilitiesService ( WorldSession session)
26  : BaseService(session)
27 {
28 }
WorldserverService< game_utilities::v1::GameUtilitiesService > BaseService
Definition: WorldserverService.h:57

Member Function Documentation

uint32 Battlenet::GameUtilitiesService::HandleGetAllValuesForAttribute ( game_utilities::v1::GetAllValuesForAttributeRequest const request,
game_utilities::v1::GetAllValuesForAttributeResponse response 
)
override
108 {
109  if (request->attribute_key() == "Command_RealmListRequest_v1_b9")
110  {
111  sRealmList->WriteSubRegions(response);
112  return ERROR_OK;
113  }
114 
116 }
Definition: BattlenetRpcErrorCodes.h:233
Definition: BattlenetRpcErrorCodes.h:25
#define sRealmList
Definition: RealmList.h:101

+ Here is the call graph for this function:

uint32 Battlenet::GameUtilitiesService::HandleProcessClientRequest ( game_utilities::v1::ClientRequest const request,
game_utilities::v1::ClientResponse response 
)
override
31 {
32  Attribute const* command = nullptr;
33  std::unordered_map<std::string, Variant const*> params;
34 
35  for (int32 i = 0; i < request->attribute_size(); ++i)
36  {
37  Attribute const& attr = request->attribute(i);
38  params[attr.name()] = &attr.value();
39  if (strstr(attr.name().c_str(), "Command_") == attr.name().c_str())
40  command = &attr;
41  }
42 
43  if (!command)
44  {
45  TC_LOG_ERROR("session.rpc", "%s sent ClientRequest with no command.", GetCallerInfo().c_str());
47  }
48 
49  if (command->name() == "Command_RealmListRequest_v1_b9")
50  return HandleRealmListRequest(params, response);
51  else if (command->name() == "Command_RealmJoinRequest_v1_b9")
52  return HandleRealmJoinRequest(params, response);
53 
55 }
const ::std::string & name() const
Definition: attribute_types.pb.h:931
uint32 HandleRealmJoinRequest(std::unordered_map< std::string, Variant const * > params, game_utilities::v1::ClientResponse *response)
Definition: WorldserverService.cpp:97
std::string GetCallerInfo() const override
Definition: WorldserverService.h:50
uint32 HandleRealmListRequest(std::unordered_map< std::string, Variant const * > params, game_utilities::v1::ClientResponse *response)
Definition: WorldserverService.cpp:57
Definition: BattlenetRpcErrorCodes.h:231
Definition: BattlenetRpcErrorCodes.h:233
const ::bgs::protocol::Variant & value() const
Definition: attribute_types.pb.h:1005
int32_t int32
Definition: Define.h:146
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::set< uint32 > params[2]
Definition: DisableMgr.cpp:45
Definition: attribute_types.pb.h:248

+ Here is the call graph for this function:

uint32 Battlenet::GameUtilitiesService::HandleRealmJoinRequest ( std::unordered_map< std::string, Variant const * >  params,
game_utilities::v1::ClientResponse response 
)
private
98 {
99  auto realmAddress = params.find("Param_RealmAddress");
100  if (realmAddress != params.end())
101  return sRealmList->JoinRealm(realmAddress->second->uint_value(), realm.Build, boost::asio::ip::address::from_string(_session->GetRemoteAddress()), _session->GetRealmListSecret(),
103 
105 }
Realm realm
Definition: World.cpp:3485
std::string const & GetAccountName() const
Definition: WorldSession.h:924
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
WorldSession * _session
Definition: WorldserverService.h:52
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
Definition: BattlenetRpcErrorCodes.h:643
uint32 Build
Definition: Realm.h:87
#define sRealmList
Definition: RealmList.h:101
std::string const & GetOS() const
Definition: WorldSession.h:935
std::array< uint8, 32 > const & GetRealmListSecret() const
Definition: WorldSession.h:1707
uint32 Battlenet::GameUtilitiesService::HandleRealmListRequest ( std::unordered_map< std::string, Variant const * >  params,
game_utilities::v1::ClientResponse response 
)
private
58 {
59  std::string subRegionId;
60  auto subRegion = params.find("Command_RealmListRequest_v1_b9");
61  if (subRegion != params.end())
62  subRegionId = subRegion->second->string_value();
63 
64  std::vector<uint8> compressed = sRealmList->GetRealmList(realm.Build, subRegionId);
65 
66  if (compressed.empty())
68 
69  Attribute* attribute = response->add_attribute();
70  attribute->set_name("Param_RealmList");
71  attribute->mutable_value()->set_blob_value(compressed.data(), compressed.size());
72 
73  JSON::RealmList::RealmCharacterCountList realmCharacterCounts;
74  for (auto const& characterCount : _session->GetRealmCharacterCounts())
75  {
76  ::JSON::RealmList::RealmCharacterCountEntry* countEntry = realmCharacterCounts.add_counts();
77  countEntry->set_wowrealmaddress(characterCount.first);
78  countEntry->set_count(characterCount.second);
79  }
80 
81  std::string json = "JSONRealmCharacterCountList:" + JSON::Serialize(realmCharacterCounts);
82 
83  uLongf compressedLength = compressBound(json.length());
84  compressed.resize(4 + compressedLength);
85  *reinterpret_cast<uint32*>(compressed.data()) = json.length() + 1;
86 
87  if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), json.length() + 1) != Z_OK)
89 
90  attribute = response->add_attribute();
91  attribute->set_name("Param_CharacterCountList");
92  attribute->mutable_value()->set_blob_value(compressed.data(), compressedLength + 4);
93 
94  return ERROR_OK;
95 }
void set_name(const ::std::string &value)
Definition: attribute_types.pb.h:935
Realm realm
Definition: World.cpp:3485
inline::bgs::protocol::Variant * mutable_value()
Definition: attribute_types.pb.h:1009
TC_SHARED_API std::string Serialize(google::protobuf::Message const &message)
Definition: ProtobufJSON.cpp:438
WorldSession * _session
Definition: WorldserverService.h:52
Definition: RealmList.pb.h:542
uint32_t uint32
Definition: Define.h:150
uint32 Build
Definition: Realm.h:87
Definition: RealmList.pb.h:466
void set_count(::google::protobuf::uint32 value)
Definition: RealmList.pb.h:1814
inline::bgs::protocol::Attribute * add_attribute()
Definition: game_utilities_service.pb.h:1617
Definition: BattlenetRpcErrorCodes.h:25
uLong FAR uLongf
Definition: zconf.h:382
Definition: BattlenetRpcErrorCodes.h:604
#define sRealmList
Definition: RealmList.h:101
#define Z_OK
Definition: zlib.h:173
uint8_t uint8
Definition: Define.h:152
#define const
Definition: zconf.h:217
void set_wowrealmaddress(::google::protobuf::uint32 value)
Definition: RealmList.pb.h:1790
inline::JSON::RealmList::RealmCharacterCountEntry * add_counts()
Definition: RealmList.pb.h:1839
std::unordered_map< uint32, uint8 > const & GetRealmCharacterCounts() const
Definition: WorldSession.h:1710
Definition: attribute_types.pb.h:248

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: