diff options
Diffstat (limited to 'server-beta/src/brave')
-rw-r--r-- | server-beta/src/brave/brave.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/server-beta/src/brave/brave.lua b/server-beta/src/brave/brave.lua index 93a93142..08909074 100644 --- a/server-beta/src/brave/brave.lua +++ b/server-beta/src/brave/brave.lua @@ -4,12 +4,21 @@ local thread = require 'bee.thread' local m = {} m.type = 'brave' m.ability = {} +m.queue = {} --- 注册成为勇者 function m.register(id) m.taskpad = thread.channel('taskpad' .. id) m.waiter = thread.channel('waiter' .. id) m.id = id + + if #m.queue > 0 then + for _, info in ipairs(m.queue) do + m.waiter:push(info.name, info.params) + end + end + m.queue = nil + m.start() end @@ -20,7 +29,14 @@ end --- 报告 function m.push(name, params) - m.waiter:push(name, params) + if m.waiter then + m.waiter:push(name, params) + else + m.queue[#m.queue+1] = { + name = name, + params = params, + } + end end --- 开始找工作 |