Mercurial Hosting > luan
diff core/src/luan/modules/Rpc.luan @ 743:2c41f2aec92f
improve Rpc and implement rpc call for local webserver
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 13 Jul 2016 17:27:35 -0600 |
parents | ca169567ce07 |
children | 3f461f85243d |
line wrap: on
line diff
--- a/core/src/luan/modules/Rpc.luan Tue Jul 12 17:47:30 2016 -0600 +++ b/core/src/luan/modules/Rpc.luan Wed Jul 13 17:27:35 2016 -0600 @@ -9,10 +9,17 @@ local M = {} +M.port = 9101 + M.call = RpcLuan.call -- Rpc.call(socket,fn_name,...) -M.respond = RpcLuan.respond -- Rpc.respond(socket,fns) + +M.functions = {} -function M.remote(socket_uri) +function M.respond(socket,fns) + RpcLuan.respond( socket, fns or M.functions ) +end + +function M.remote_socket(socket_uri) local mt = {} function mt.__index(_,key) return function(...) @@ -25,6 +32,19 @@ return t end +function M.remote(domain) + local socket = "socket:" .. domain .. ":" .. M.port + return M.remote_socket(socket) +end + +function M.responder(fns) + local server = Io.socket_server(M.port) + return function() + local socket = server() + M.respond(socket,fns) + end +end + --[[ function M.serve(port,fns) local server = Io.socket_server(port)