From 9181eec174202fd799282c232d586110e05ab7d5 Mon Sep 17 00:00:00 2001 From: Michael Davis <michael.davis@cern.ch> Date: Sun, 4 Jun 2017 02:16:59 +0200 Subject: [PATCH] Serializes and sends response from XrdSsi server --- frontend/TestSsiRequestProc.cpp | 20 ++++++++++++++++++++ frontend/TestSsiRequestProc.h | 10 ++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/frontend/TestSsiRequestProc.cpp b/frontend/TestSsiRequestProc.cpp index 6e761eefa3..67f7d072eb 100644 --- a/frontend/TestSsiRequestProc.cpp +++ b/frontend/TestSsiRequestProc.cpp @@ -7,6 +7,26 @@ // This is for specialized private methods called by RequestProc::Execute to handle actions, alerts // and metadata +template <> +void RequestProc<xrdssi::test::Request, xrdssi::test::Result>::ExecuteAction() +{ + // Output message in Json format (for debugging) + + std::cerr << "Received message:" << std::endl; + std::cerr << xrdssi::test::MessageToJsonString(request); + + // Set reply + + response.set_result_code(0); + response.mutable_response()->set_message_text("This is the reply to " + *request.mutable_message_text()); + + // Output message in Json format (for debugging) + + std::cerr << "Sending response:" << std::endl; + std::cerr << xrdssi::test::MessageToJsonString(response); +} + + template <> void RequestProc<xrdssi::test::Request, xrdssi::test::Result>::ExecuteMetadata() { diff --git a/frontend/TestSsiRequestProc.h b/frontend/TestSsiRequestProc.h index 82e3e2aef9..4ac4e5d242 100644 --- a/frontend/TestSsiRequestProc.h +++ b/frontend/TestSsiRequestProc.h @@ -29,9 +29,11 @@ public: virtual void Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false) override; private: - void ExecuteAction() {} - void ExecuteAlerts() {} - void ExecuteMetadata() {} + // These methods should be specialized according to the needs of each <RequestType, ResponseType> pair + + void ExecuteAction() { std::cerr << "Called default ExecuteAction()" << std::endl; } + void ExecuteAlerts() { std::cerr << "Called default ExecuteAlerts()" << std::endl; } + void ExecuteMetadata() { std::cerr << "Called default ExecuteMetadata()" << std::endl; } RequestType request; ResponseType response; @@ -62,7 +64,7 @@ void RequestProc<RequestType, ResponseType>::Execute() throw XrdSsiException("ParseFromString() failed"); } - // Release the request buffer (optional, perhaps it is more efficient to reuse it) + // Release the request buffer (optional, perhaps it is more efficient to reuse it?) ReleaseRequestBuffer(); -- GitLab