mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-26 03:48:06 +11:00
Compare commits
2 Commits
effcadc915
...
f896547ea9
Author | SHA1 | Date | |
---|---|---|---|
f896547ea9 | |||
f7cc00822a |
15
RPC/OpenOS/usr/bin/exportcomponent.lua
Normal file
15
RPC/OpenOS/usr/bin/exportcomponent.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local component = require "component"
|
||||
local rpc = require "rpc"
|
||||
local tA = {...}
|
||||
|
||||
if #tA < 1 then
|
||||
print("Usage: exportcomponent <component address> [component address...]")
|
||||
end
|
||||
|
||||
for k,v in ipairs(tA) do
|
||||
local px = component.proxy(component.get(v))
|
||||
print(px.type.."_"..px.address)
|
||||
for l,m in pairs(px) do
|
||||
rpc.register(px.type.."_"..px.address.."_"..l,m)
|
||||
end
|
||||
end
|
29
RPC/OpenOS/usr/bin/importcomponent.lua
Normal file
29
RPC/OpenOS/usr/bin/importcomponent.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local vcomponent = require "vcomponent"
|
||||
local rpc = require "rpc"
|
||||
local tA = {...}
|
||||
local host, ctype, addr = tA[1], tA[2], tA[3]
|
||||
|
||||
if #tA < 3 then
|
||||
print("Usage: importcomponent <host> <component type> <component address>")
|
||||
return
|
||||
end
|
||||
|
||||
local saddr = addr:gsub("%-","%%-")
|
||||
|
||||
if addr:len() < 36 then
|
||||
local flist = rpc.call(host,"list")
|
||||
for k,v in pairs(flist) do
|
||||
faddr = v:match(ctype.."_("..saddr..".*)_") or faddr
|
||||
end
|
||||
end
|
||||
print(faddr)
|
||||
saddr = (faddr or addr):gsub("%-","%%-")
|
||||
local px = rpc.proxy(host,ctype.."_"..saddr..".*_")
|
||||
local mc = 0
|
||||
for k,v in pairs(px) do
|
||||
mc = mc + 1
|
||||
end
|
||||
if mc < 1 then
|
||||
error("no such remote component: "..addr)
|
||||
end
|
||||
vcomponent.register(faddr or addr, ctype, px)
|
Loading…
Reference in New Issue
Block a user