aboutsummaryrefslogtreecommitdiff
path: root/src/server/proto/ServiceBase.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-04 23:00:47 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-04 23:00:47 +0100
commit9d9ccb7be75a6bf428f4e6c397d5034770424726 (patch)
treede8195c8f21456315b410216bb509373351957c1 /src/server/proto/ServiceBase.cpp
parentfd364fe52238c11f86618e0f6de81a74d99221a7 (diff)
Core/Proto: Re-generate protobuf services optimized for CODE_SIZE (compile time) instead of SPEED
Diffstat (limited to 'src/server/proto/ServiceBase.cpp')
-rw-r--r--src/server/proto/ServiceBase.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/server/proto/ServiceBase.cpp b/src/server/proto/ServiceBase.cpp
new file mode 100644
index 00000000000..cbf5b65fd00
--- /dev/null
+++ b/src/server/proto/ServiceBase.cpp
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ServiceBase.h"
+#include "Errors.h"
+#include "Log.h"
+#include <google/protobuf/message.h>
+
+void ServiceBase::LogDisallowedMethod(uint32 methodId)
+{
+ TC_LOG_ERROR("service.protobuf", "%s Server tried to call server method %u",
+ GetCallerInfo().c_str(), methodId);
+}
+
+void ServiceBase::LogCallClientMethod(char const* methodName, char const* inputTypeName, google::protobuf::Message const* request)
+{
+ TC_LOG_DEBUG("service.protobuf", "%s Server called client method %s(%s{ %s })",
+ GetCallerInfo().c_str(), methodName, inputTypeName, request->ShortDebugString().c_str());
+}
+
+void ServiceBase::LogCallServerMethod(char const* methodName, char const* inputTypeName, google::protobuf::Message const* request)
+{
+ TC_LOG_DEBUG("service.protobuf", "%s Client called server method %s(%s{ %s }).",
+ GetCallerInfo().c_str(), methodName, inputTypeName, request->ShortDebugString().c_str());
+}
+
+void ServiceBase::LogUnimplementedServerMethod(char const* methodName, google::protobuf::Message const* request)
+{
+ TC_LOG_ERROR("service.protobuf", "%s Client tried to call not implemented method %s({ %s })",
+ GetCallerInfo().c_str(), methodName, request->ShortDebugString().c_str());
+}
+
+void ServiceBase::LogInvalidMethod(uint32 methodId)
+{
+ TC_LOG_ERROR("service.protobuf", "Bad method id %u.", methodId);
+}
+
+void ServiceBase::LogFailedParsingRequest(char const* methodName)
+{
+ TC_LOG_DEBUG("service.protobuf", "%s Failed to parse request for %s server method call.", GetCallerInfo().c_str(), methodName);
+}
+
+std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)> ServiceBase::CreateServerContinuation(uint32 token, uint32 methodId, char const* methodName, google::protobuf::Descriptor const* outputDescriptor)
+{
+ return [token, methodId, methodName, outputDescriptor](ServiceBase* service, uint32 status, ::google::protobuf::Message const* response)
+ {
+ ASSERT(response->GetDescriptor() == outputDescriptor);
+ TC_LOG_DEBUG("service.protobuf", "%s Client called server method %s() %s{ %s } status %u.",
+ service->GetCallerInfo().c_str(), methodName, outputDescriptor->full_name().c_str(), response->ShortDebugString().c_str(), status);
+ if (!status)
+ service->SendResponse(service->GetServiceHash(), methodId, token, response);
+ else
+ service->SendResponse(service->GetServiceHash(), methodId, token, status);
+ };
+}