You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
665 B
Lua

local skynet = require "skynet"
local st = require "skynet.sharetable"
local mc = require "skynet.multicast"
local channel
local CMD = {}
function CMD.query(filename)
assert(channel)
return st.query(filename)
end
function CMD.loadfiles(filenames)
assert(type(filenames) == "table")
for _, filename in pairs(filenames) do
st.loadfile(filename)
end
channel:publish(filenames)
end
function CMD.channel()
return channel.channel
end
skynet.start(function()
channel = mc.new()
skynet.dispatch("lua", function(_, _, cmd, ...)
local f = CMD[cmd]
assert(f, cmd)
skynet.retpack(f(...))
end)
end)