diff options
Diffstat (limited to 'script/proto/proto.lua')
-rw-r--r-- | script/proto/proto.lua | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/script/proto/proto.lua b/script/proto/proto.lua index dff7063d..b432a3d1 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -156,7 +156,9 @@ local secretOption = { end } -function m.doMethod(proto) +m.methodQueue = {} + +function m.applyMethod(proto) logRecieve(proto) local method, optional = m.getMethodName(proto) local abil = m.ability[method] @@ -202,6 +204,30 @@ function m.doMethod(proto) end) end +function m.applyMethodQueue() + local queue = m.methodQueue + m.methodQueue = {} + local canceled = {} + for _, proto in ipairs(queue) do + if proto.method == '$/cancelRequest' then + canceled[proto.params.id] = true + end + end + for _, proto in ipairs(queue) do + if not canceled[proto.id] then + m.applyMethod(proto) + end + end +end + +function m.doMethod(proto) + m.methodQueue[#m.methodQueue+1] = proto + if #m.methodQueue > 1 then + return + end + timer.wait(0, m.applyMethodQueue) +end + function m.close(id, reason, message) local proto = m.holdon[id] if not proto then |