diff options
author | chai <chaifix@163.com> | 2021-10-20 19:36:15 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-20 19:36:15 +0800 |
commit | f2dcd16fc72e2f10c9504897bacf5c4c2ecff516 (patch) | |
tree | 29cb7704db0e75bb16b31c1541abcf871f623cd8 /Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua | |
parent | afdcbfa9c4259fb003fd072ae011836230e7e39b (diff) |
+lua libs
Diffstat (limited to 'Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua')
-rw-r--r-- | Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua b/Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua new file mode 100644 index 0000000..f265b8a --- /dev/null +++ b/Resources/DefaultContent/Libraries/json4lua/examples/jsonrpc.lua @@ -0,0 +1,21 @@ +--
+-- jsonrpc.lua
+-- Installed in a CGILua webserver environment (with necessary CGI Lua 5.0 patch)
+--
+require ('json.rpcserver')
+
+-- The Lua class that is to serve JSON RPC requests
+local myServer = {
+ echo = function (msg) return msg end,
+ average = function(...)
+ local total=0
+ local count=0
+ for i=1, table.getn(arg) do
+ total = total + arg[i]
+ count = count + 1
+ end
+ return { average= total/count, sum = total, n=count }
+ end
+}
+
+json.rpcserver.serve(myServer)
\ No newline at end of file |