30 {
"Command_RealmListRequest_v1", &GameUtilitiesService::HandleRealmListRequest },
31 {
"Command_RealmJoinRequest_v1", &GameUtilitiesService::HandleRealmJoinRequest }
41 std::unordered_map<std::string, Variant const*>
params;
42 auto removeSuffix = [](std::string
const& string) -> std::string
44 size_t pos =
string.rfind(
'_');
45 if (pos != std::string::npos)
46 return string.substr(0, pos);
51 for (
int32 i = 0; i < request->attribute_size(); ++i)
53 Attribute const& attr = request->attribute(i);
54 if (strstr(attr.
name().c_str(),
"Command_") == attr.
name().c_str())
65 TC_LOG_ERROR(
"session.rpc",
"{} sent ClientRequest with no command.", GetCallerInfo());
69 auto itr = ClientRequestHandlers.find(removeSuffix(command->
name()));
70 if (itr == ClientRequestHandlers.end())
72 TC_LOG_ERROR(
"session.rpc",
"{} sent ClientRequest with unknown command {}.", GetCallerInfo(), removeSuffix(command->
name()));
76 return (this->*itr->second)(
params, response);
81 std::string subRegionId;
83 subRegionId = subRegion->string_value();
85 std::vector<uint8> compressed =
sRealmList->GetRealmList(_session->GetClientBuild(), _session->GetSecurity(), subRegionId);
87 if (compressed.empty())
90 Attribute* attribute = response->add_attribute();
91 attribute->
set_name(
"Param_RealmList");
95 for (
auto const& characterCount : _session->GetRealmCharacterCounts())
99 countEntry->
set_count(characterCount.second);
102 std::string json =
"JSONRealmCharacterCountList:" +
JSON::Serialize(realmCharacterCounts);
104 uLongf compressedLength = compressBound(json.length());
105 compressed.resize(4 + compressedLength);
106 *
reinterpret_cast<uint32*
>(compressed.data()) = json.length() + 1;
108 if (compress(compressed.data() + 4, &compressedLength,
reinterpret_cast<uint8 const*
>(json.c_str()), json.length() + 1) != Z_OK)
111 attribute = response->add_attribute();
112 attribute->
set_name(
"Param_CharacterCountList");
121 return sRealmList->JoinRealm(
uint32(realmAddress->uint_value()), _session->GetClientBuild(), _session->GetClientBuildVariant(),
122 Trinity::Net::make_address(_session->GetRemoteAddress()), _session->GetRealmListSecret(), _session->GetSessionDbcLocale(),
123 _session->GetOS(), _session->GetTimezoneOffset(), _session->GetAccountName(), _session->GetSecurity(), response);
130 if (request->attribute_key().find(
"Command_RealmListRequest_v1") == 0)
@ ERROR_RPC_NOT_IMPLEMENTED
@ ERROR_RPC_MALFORMED_REQUEST
@ ERROR_WOW_SERVICES_INVALID_JOIN_TICKET
@ ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE
std::unordered_set< uint32 > params[2]
#define TC_LOG_ERROR(filterType__, message__,...)
GameUtilitiesService(WorldSession *session)
uint32 HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const *request, game_utilities::v1::GetAllValuesForAttributeResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
static std::unordered_map< std::string, ClientRequestHandler > const ClientRequestHandlers
uint32 HandleRealmJoinRequest(std::unordered_map< std::string, Variant const * > const ¶ms, game_utilities::v1::ClientResponse *response)
uint32 HandleRealmListRequest(std::unordered_map< std::string, Variant const * > const ¶ms, game_utilities::v1::ClientResponse *response)
uint32 HandleProcessClientRequest(game_utilities::v1::ClientRequest const *request, game_utilities::v1::ClientResponse *response, std::function< void(ServiceBase *, uint32, ::google::protobuf::Message const *)> &continuation) override
void set_wowrealmaddress(::google::protobuf::uint32 value)
void set_count(::google::protobuf::uint32 value)
inline ::JSON::RealmList::RealmCharacterCountEntry * add_counts()
Player session in the World.
const ::bgs::protocol::Variant & value() const
const ::std::string & name() const
inline ::bgs::protocol::Variant * mutable_value()
void set_name(const ::std::string &value)
void set_blob_value(const ::std::string &value)
TC_SHARED_API std::string Serialize(google::protobuf::Message const &message)
auto MapGetValuePtr(M &map, typename M::key_type const &key)