Mercurial Hosting > luan
changeset 742:5578541125ea
add Hosting.caller()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Jul 2016 17:47:30 -0600 |
parents | 9f58b398a892 |
children | 2c41f2aec92f |
files | core/src/luan/modules/RpcLuan.java core/src/luan/modules/host/Hosting.luan |
diffstat | 2 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
diff -r 9f58b398a892 -r 5578541125ea core/src/luan/modules/RpcLuan.java --- a/core/src/luan/modules/RpcLuan.java Mon Jul 11 03:56:18 2016 -0600 +++ b/core/src/luan/modules/RpcLuan.java Tue Jul 12 17:47:30 2016 -0600 @@ -73,7 +73,7 @@ for( int i=0; i<nArgs; i++ ) { args[i] = readObj(in,luan); } - LuanFunction fn = (LuanFunction)fns.rawGet(fnName); + LuanFunction fn = (LuanFunction)fns.get(luan,fnName); if( fn == null ) throw new LuanException( "function not found: " + fnName ); rtn = Luan.array(fn.call(luan,args));
diff -r 9f58b398a892 -r 5578541125ea core/src/luan/modules/host/Hosting.luan --- a/core/src/luan/modules/host/Hosting.luan Mon Jul 11 03:56:18 2016 -0600 +++ b/core/src/luan/modules/host/Hosting.luan Tue Jul 12 17:47:30 2016 -0600 @@ -4,6 +4,7 @@ local error = Luan.error local ipairs = Luan.ipairs or error() local pairs = Luan.pairs or error() +local set_metatable = Luan.set_metatable or error() local Io = require "luan:Io.luan" local print = Io.print or error() local Rpc = require "luan:Rpc.luan" @@ -86,4 +87,18 @@ return host.change_password(domain,old_password,new_password) end +function M.caller(domain) + local socket = "socket:" .. domain .. ":" .. M.port + local host = Rpc.remote(socket) + local mt = {} + function mt.__index(_,key) + return function(...) + return host.call(domain,key,...) + end + end + local t = {} + set_metatable(t,mt) + return t +end + return M