diff core/src/luan/modules/host/Hosting.luan @ 742:5578541125ea

add Hosting.caller()
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 Jul 2016 17:47:30 -0600
parents 6871ba08d521
children 2c41f2aec92f
line wrap: on
line diff
--- 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