aboutsummaryrefslogtreecommitdiffstats
path: root/jrt_test/src/tests/mockup-invoke/mockup-server.cpp
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jrt_test/src/tests/mockup-invoke/mockup-server.cpp
Publish
Diffstat (limited to 'jrt_test/src/tests/mockup-invoke/mockup-server.cpp')
-rw-r--r--jrt_test/src/tests/mockup-invoke/mockup-server.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/jrt_test/src/tests/mockup-invoke/mockup-server.cpp b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp
new file mode 100644
index 00000000000..97b2e945e57
--- /dev/null
+++ b/jrt_test/src/tests/mockup-invoke/mockup-server.cpp
@@ -0,0 +1,69 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/log/log.h>
+LOG_SETUP("mockup_server");
+#include <vespa/fastos/fastos.h>
+#include <vespa/fnet/frt/frt.h>
+
+
+class MockupServer : public FRT_Invokable
+{
+private:
+ MockupServer(const MockupServer &);
+ MockupServer &operator=(const MockupServer &);
+
+public:
+ MockupServer(FRT_Supervisor *s)
+ {
+ FRT_ReflectionBuilder rb(s);
+ //-------------------------------------------------------------------
+ rb.DefineMethod("concat", "ss", "s", true,
+ FRT_METHOD(MockupServer::RPC_concat), this);
+ rb.MethodDesc("Concatenate two strings");
+ rb.ParamDesc("string1", "a string");
+ rb.ParamDesc("string2", "another string");
+ rb.ReturnDesc("ret", "the concatenation of string1 and string2");
+ //-------------------------------------------------------------------
+ }
+
+ void RPC_concat(FRT_RPCRequest *req)
+ {
+ FRT_Values &params = *req->GetParams();
+ FRT_Values &ret = *req->GetReturn();
+
+ uint32_t len = (params[0]._string._len +
+ params[1]._string._len);
+ char *tmp = ret.AddString(len);
+ strcpy(tmp, params[0]._string._str);
+ strcat(tmp, params[1]._string._str);
+ }
+};
+
+
+class App : public FastOS_Application
+{
+public:
+ int Main();
+};
+
+
+int
+App::Main()
+{
+ if (_argc < 2) {
+ printf("usage: %s <listenspec>\n", _argv[0]);
+ return 1;
+ }
+ FRT_Supervisor orb;
+ MockupServer server(&orb);
+ orb.Listen(_argv[1]);
+ orb.Main();
+ return 0;
+}
+
+
+int
+main(int argc, char **argv)
+{
+ App myapp;
+ return myapp.Entry(argc, argv);
+}