summaryrefslogtreecommitdiff
path: root/script/pub/pub.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-02 14:43:30 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-02 14:43:30 +0800
commit07d37e7b5d4fd1841dbc3fdfb5b17759f2f79baf (patch)
tree8321269da4ade48dc229b03115b69035e5e5b5c5 /script/pub/pub.lua
parent5e9e75b46fdacda1bb1479780af6a0132d7d17cb (diff)
downloadlua-language-server-07d37e7b5d4fd1841dbc3fdfb5b17759f2f79baf.zip
multi-compile use private channel
Diffstat (limited to 'script/pub/pub.lua')
-rw-r--r--script/pub/pub.lua19
1 files changed, 15 insertions, 4 deletions
diff --git a/script/pub/pub.lua b/script/pub/pub.lua
index 1e9b6c8f..9733846a 100644
--- a/script/pub/pub.lua
+++ b/script/pub/pub.lua
@@ -24,7 +24,7 @@ log = require 'brave.log'
xpcall(dofile, log.error, %q)
local brave = require 'brave'
-brave.register(%d)
+brave.register(%d, %q)
]]
---@class pub
@@ -34,6 +34,7 @@ m.braves = {}
m.ability = {}
m.taskQueue = {}
m.taskMap = {}
+m.prvtPad = {}
--- 注册酒馆的功能
function m.on(name, callback)
@@ -42,7 +43,8 @@ end
--- 招募勇者,勇者会从公告板上领取任务,完成任务后到看板娘处交付任务
---@param num integer
-function m.recruitBraves(num)
+---@param privatePad string?
+function m.recruitBraves(num, privatePad)
for _ = 1, num do
local id = #m.braves + 1
log.debug('Create brave:', id)
@@ -55,13 +57,18 @@ function m.recruitBraves(num)
DBGPORT or 11412,
DBGWAIT or 'nil',
(ROOT / 'debugger.lua'):string(),
- id
+ id,
+ privatePad
)),
taskMap = {},
currentTask = nil,
memory = 0,
}
end
+ if privatePad and not m.prvtPad[privatePad] then
+ thread.newchannel('private:' .. privatePad)
+ m.prvtPad[privatePad] = thread.channel('private:' .. privatePad)
+ end
end
--- 给勇者推送任务
@@ -69,7 +76,11 @@ function m.pushTask(info)
if info.removed then
return false
end
- taskPad:push(info.name, info.id, info.params)
+ if m.prvtPad[info.name] then
+ m.prvtPad[info.name]:push(info.name, info.id, info.params)
+ else
+ taskPad:push(info.name, info.id, info.params)
+ end
m.taskMap[info.id] = info
return true
end