diff --git a/frontend/Makefile b/frontend/Makefile index e23a3b0c615edd4479119df69f88becc0c5c3ce7..b80762d6ff346f04929d5f4efefaa57d2ebbf644 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -1,7 +1,12 @@ CPPFLAGS=-I/usr/include/xrootd -fPIC -std=c++11 LDFLAGS=-lXrdSsi-4 -lXrdSsiLib +LINK.o=$(LINK.cc) -all: frontend_ssi.so +all: test_client frontend_ssi.so + +test_client: test_client.o + +test_client.o: test_client.cpp TestSsiService.h frontend_ssi.so: frontend_ssi.o $(LINK.cc) -shared $^ $(LOADLIBES) $(LDLIBS) -o $@ diff --git a/frontend/test_client.cpp b/frontend/test_client.cpp index 32c124ffdaf0465a1a0b86e01c320694dbc87661..64312cfcf938c132323cca22933d6c324b4eb44a 100644 --- a/frontend/test_client.cpp +++ b/frontend/test_client.cpp @@ -1,35 +1,61 @@ -#include <iostream> +#include <unistd.h> // for sleep -#include <google/protobuf/util/json_util.h> // for Json output - -#include "test.pb.h" +#include "TestSsiService.h" int main(int argc, char *argv[]) { - using namespace std; + // Obtain a Service Provider - // Verify that the version of the library that we linked against is compatible with the version of - // the headers we compiled against. + const std::string host = "localhost"; + const int port = 10400; - GOOGLE_PROTOBUF_VERIFY_VERSION; + try + { + TestSsiService test_ssi_service(host, port); + } + catch (std::exception& e) + { + std::cerr << "TestSsiService() failed with error: " << e.what() << std::endl; - eos::wfe::Request request; + return 1; + } - request.set_message_text("Archive some file"); + // Initiate a Request - // Output message in Json format +#if 0 + // Requests are always executed in the context of a service. They need to correspond to what the service allows. - google::protobuf::util::JsonPrintOptions options; - options.add_whitespace = true; - options.always_print_primitive_fields = true; - string jsonNotification; - google::protobuf::util::MessageToJsonString(request, &jsonNotification, options); - cout << "Sending message:" << endl << jsonNotification; + XrdSsiRequest *theRequest; // Used for demonstration purposes - // Optional: Delete all global objects allocated by libprotobuf + // Create a request object (upcast from your implementation) - google::protobuf::ShutdownProtobufLibrary(); + int reqDLen = 1024; + char reqData[reqDLen]; - return 0; -} + theRequest = new MyRequest(reqData, reqDLen, 5); + + // Transfer ownership of the request to the service object + + servP->ProcessRequest(*theRequest, theResource); + + // MyRequest object handles deletion of the data buffer, we shall never mention this pointer again... + + theRequest = NULL; + // Note: it is safe to delete the XrdSsiResource object after ProcessRequest() returns. +#endif + + // Wait for the response callback + + std::cout << "Request sent, going to sleep..." << std::endl; + + int wait_secs = 40; + + while(--wait_secs) + { + std::cerr << "."; + sleep(1); + } + + std::cout << "All done, exiting." << std::endl; +}