31 {
"Command_RealmListRequest_v1", &GameUtilitiesService::HandleRealmListRequest },
32 {
"Command_RealmJoinRequest_v1", &GameUtilitiesService::HandleRealmJoinRequest }
42 std::unordered_map<std::string, Variant const*>
params;
43 auto removeSuffix = [](std::string
const& string) -> std::string
45 size_t pos =
string.rfind(
'_');
46 if (pos != std::string::npos)
47 return string.substr(0, pos);
52 for (
int32 i = 0; i < request->attribute_size(); ++i)
54 Attribute const& attr = request->attribute(i);
55 if (strstr(attr.
name().c_str(),
"Command_") == attr.
name().c_str())
66 TC_LOG_ERROR(
"session.rpc",
"{} sent ClientRequest with no command.", GetCallerInfo());
70 auto itr = ClientRequestHandlers.find(removeSuffix(command->
name()));
71 if (itr == ClientRequestHandlers.end())
73 TC_LOG_ERROR(
"session.rpc",
"{} sent ClientRequest with unknown command {}.", GetCallerInfo(), removeSuffix(command->
name()));
77 return (this->*itr->second)(
params, response);
80static Variant const*
GetParam(std::unordered_map<std::string, Variant const*>
const&
params,
char const* paramName)
82 auto itr =
params.find(paramName);
83 return itr !=
params.end() ? itr->second :
nullptr;
88 std::string subRegionId;
90 subRegionId = subRegion->string_value();
94 if (compressed.empty())
97 Attribute* attribute = response->add_attribute();
98 attribute->
set_name(
"Param_RealmList");
102 for (
auto const& characterCount : _session->GetRealmCharacterCounts())
106 countEntry->
set_count(characterCount.second);
109 std::string json =
"JSONRealmCharacterCountList:" +
JSON::Serialize(realmCharacterCounts);
111 uLongf compressedLength = compressBound(json.length());
112 compressed.resize(4 + compressedLength);
113 *
reinterpret_cast<uint32*
>(compressed.data()) = json.length() + 1;
115 if (compress(compressed.data() + 4, &compressedLength,
reinterpret_cast<uint8 const*
>(json.c_str()), json.length() + 1) != Z_OK)
118 attribute = response->add_attribute();
119 attribute->
set_name(
"Param_CharacterCountList");
128 return sRealmList->JoinRealm(
uint32(realmAddress->uint_value()),
realm.
Build, Trinity::Net::make_address(_session->GetRemoteAddress()), _session->GetRealmListSecret(),
129 _session->GetSessionDbcLocale(), _session->GetOS(), _session->GetTimezoneOffset(), _session->GetAccountName(), response);
136 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__,...)
static Variant const * GetParam(std::unordered_map< std::string, Variant const * > const ¶ms, char const *paramName)
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)