aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Services
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-09-21 21:59:59 +0200
committerShauren <shauren.trinity@gmail.com>2017-09-21 21:59:59 +0200
commit3269a68427bcfa200837281c336cbedc3d114dd1 (patch)
treefc69a05185a21533af4133a8f2186850889d52b8 /src/server/game/Services
parent115dffde983019acb1f167583b60f0ce1aaa90de (diff)
Core/Bnet: Implement a way to handle turn protobuf service calls into async requests
Diffstat (limited to 'src/server/game/Services')
-rw-r--r--src/server/game/Services/WorldserverService.cpp4
-rw-r--r--src/server/game/Services/WorldserverService.h4
-rw-r--r--src/server/game/Services/WorldserverServiceDispatcher.cpp2
-rw-r--r--src/server/game/Services/WorldserverServiceDispatcher.h6
4 files changed, 9 insertions, 7 deletions
diff --git a/src/server/game/Services/WorldserverService.cpp b/src/server/game/Services/WorldserverService.cpp
index 779bb10adac..a1fc28b9625 100644
--- a/src/server/game/Services/WorldserverService.cpp
+++ b/src/server/game/Services/WorldserverService.cpp
@@ -30,7 +30,7 @@ Battlenet::GameUtilitiesService::GameUtilitiesService(WorldSession* session) : B
{
}
-uint32 Battlenet::GameUtilitiesService::HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response)
+uint32 Battlenet::GameUtilitiesService::HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/)
{
Attribute const* command = nullptr;
std::unordered_map<std::string, Variant const*> params;
@@ -107,7 +107,7 @@ uint32 Battlenet::GameUtilitiesService::HandleRealmJoinRequest(std::unordered_ma
return ERROR_WOW_SERVICES_INVALID_JOIN_TICKET;
}
-uint32 Battlenet::GameUtilitiesService::HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const* request, game_utilities::v1::GetAllValuesForAttributeResponse* response)
+uint32 Battlenet::GameUtilitiesService::HandleGetAllValuesForAttribute(game_utilities::v1::GetAllValuesForAttributeRequest const* request, game_utilities::v1::GetAllValuesForAttributeResponse* response, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& /*continuation*/)
{
if (request->attribute_key() == "Command_RealmListRequest_v1_b9")
{
diff --git a/src/server/game/Services/WorldserverService.h b/src/server/game/Services/WorldserverService.h
index 54bb3a076c5..90eaf80f229 100644
--- a/src/server/game/Services/WorldserverService.h
+++ b/src/server/game/Services/WorldserverService.h
@@ -59,8 +59,8 @@ namespace Battlenet
public:
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;
+ 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;
private:
uint32 HandleRealmListRequest(std::unordered_map<std::string, Variant const*> params, game_utilities::v1::ClientResponse* response);
diff --git a/src/server/game/Services/WorldserverServiceDispatcher.cpp b/src/server/game/Services/WorldserverServiceDispatcher.cpp
index 3e640542a1b..2dfbe3ec23d 100644
--- a/src/server/game/Services/WorldserverServiceDispatcher.cpp
+++ b/src/server/game/Services/WorldserverServiceDispatcher.cpp
@@ -37,7 +37,7 @@ void Battlenet::WorldserverServiceDispatcher::Dispatch(WorldSession* session, ui
{
auto itr = _dispatchers.find(serviceHash);
if (itr != _dispatchers.end())
- itr->second(session, token, methodId, std::forward<MessageBuffer>(buffer));
+ itr->second(session, token, methodId, std::move(buffer));
else
TC_LOG_DEBUG("session.rpc", "%s tried to call invalid service 0x%X", session->GetPlayerInfo().c_str(), serviceHash);
}
diff --git a/src/server/game/Services/WorldserverServiceDispatcher.h b/src/server/game/Services/WorldserverServiceDispatcher.h
index c84aa1f40cc..99e9446f80e 100644
--- a/src/server/game/Services/WorldserverServiceDispatcher.h
+++ b/src/server/game/Services/WorldserverServiceDispatcher.h
@@ -55,10 +55,12 @@ namespace Battlenet
template<class Service>
static void Dispatch(WorldSession* session, uint32 token, uint32 methodId, MessageBuffer buffer)
{
- Service(session).CallServerMethod(token, methodId, std::forward<MessageBuffer>(buffer));
+ Service(session).CallServerMethod(token, methodId, std::move(buffer));
}
- std::unordered_map<uint32, std::function<void(WorldSession*, uint32, uint32, MessageBuffer)>> _dispatchers;
+ typedef void(*ServiceMethod)(WorldSession*, uint32, uint32, MessageBuffer);
+ // use identity hashing for map keys as they are already a hash (FNV1a of service name)
+ std::unordered_map<uint32, ServiceMethod, std::identity<uint32>> _dispatchers;
};
}