aboutsummaryrefslogtreecommitdiff
path: root/src/server/bnetserver/Services/Service.h
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-06-12 20:51:28 +0200
committerShauren <shauren.trinity@gmail.com>2025-06-12 20:51:28 +0200
commit805f8e68177e04827f7be8afc351ad59b97cafbb (patch)
treeac8666d7912db42517c2a8f306c5121ec3176279 /src/server/bnetserver/Services/Service.h
parent7002766c0a72b3919011c422e0bdb83422bc7ddc (diff)
Core/Bnet: Update PCH content to include most commonly used headers
Diffstat (limited to 'src/server/bnetserver/Services/Service.h')
-rw-r--r--src/server/bnetserver/Services/Service.h66
1 files changed, 53 insertions, 13 deletions
diff --git a/src/server/bnetserver/Services/Service.h b/src/server/bnetserver/Services/Service.h
index 9dcbb685a66..b4907c22bb2 100644
--- a/src/server/bnetserver/Services/Service.h
+++ b/src/server/bnetserver/Services/Service.h
@@ -15,31 +15,71 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef Service_h__
-#define Service_h__
+#ifndef TRINITYCORE_BNET_SERVICE_H
+#define TRINITYCORE_BNET_SERVICE_H
-#include "Session.h"
+#include "MessageBuffer.h"
+#include <functional>
+#include <string>
-namespace bgs { namespace protocol { } }
+namespace google::protobuf
+{
+class Message;
+}
+
+namespace bgs::protocol { }
using namespace bgs::protocol;
namespace Battlenet
{
+ class Session;
+
+ class ServiceBaseCaller
+ {
+ protected:
+ explicit ServiceBaseCaller(Session* session) : _session(session) { }
+
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request, std::function<void(MessageBuffer)>&& callback);
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request);
+ void SendResponse(uint32 serviceHash, uint32 methodId, uint32 token, uint32 status);
+ void SendResponse(uint32 serviceHash, uint32 methodId, uint32 token, google::protobuf::Message const* response);
+ std::string GetCallerInfo() const;
+
+ Session* _session;
+ };
+
template<class T>
- class Service : public T
+ class Service : public T, public ServiceBaseCaller
{
public:
- Service(Session* session) : T(true), _session(session) { }
+ explicit Service(Session* session) : T(true), ServiceBaseCaller(session) { }
protected:
- void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request, std::function<void(MessageBuffer)> callback) override { _session->SendRequest(serviceHash, methodId, request, std::move(callback)); }
- void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request) override { _session->SendRequest(serviceHash, methodId, request); }
- void SendResponse(uint32 /*serviceHash*/, uint32 /*methodId*/, uint32 token, uint32 status) override { _session->SendResponse(token, status); }
- void SendResponse(uint32 /*serviceHash*/, uint32 /*methodId*/, uint32 token, google::protobuf::Message const* response) override { _session->SendResponse(token, response); }
- std::string GetCallerInfo() const override { return _session->GetClientInfo(); }
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request, std::function<void(MessageBuffer)> callback) override
+ {
+ ServiceBaseCaller::SendRequest(serviceHash, methodId, request, std::move(callback));
+ }
- Session* _session;
+ void SendRequest(uint32 serviceHash, uint32 methodId, google::protobuf::Message const* request) override
+ {
+ ServiceBaseCaller::SendRequest(serviceHash, methodId, request);
+ }
+
+ void SendResponse(uint32 serviceHash, uint32 methodId, uint32 token, uint32 status) override
+ {
+ ServiceBaseCaller::SendResponse(serviceHash, methodId, token, status);
+ }
+
+ void SendResponse(uint32 serviceHash, uint32 methodId, uint32 token, google::protobuf::Message const* response) override
+ {
+ ServiceBaseCaller::SendResponse(serviceHash, methodId, token, response);
+ }
+
+ std::string GetCallerInfo() const override
+ {
+ return ServiceBaseCaller::GetCallerInfo();
+ }
};
}
-#endif // Service_h__
+#endif // TRINITYCORE_BNET_SERVICE_H