diff options
Diffstat (limited to 'server-beta/src/pub')
-rw-r--r-- | server-beta/src/pub/init.lua | 15 | ||||
-rw-r--r-- | server-beta/src/pub/pub.lua | 13 |
2 files changed, 14 insertions, 14 deletions
diff --git a/server-beta/src/pub/init.lua b/server-beta/src/pub/init.lua index 65343d64..fbac27f5 100644 --- a/server-beta/src/pub/init.lua +++ b/server-beta/src/pub/init.lua @@ -1,4 +1,5 @@ -local pub = require 'pub.pub' +local pub = require 'pub.pub' +local task = require 'task' pub.on('log', function (params, brave) log.raw(brave.id, params.level, params.msg, params.src, params.line) @@ -10,11 +11,13 @@ end) pub.on('proto', function (params) local proto = require 'proto' - if params.method then - proto.doMethod(params) - else - proto.doResponse(params) - end + task.create(function () + if params.method then + proto.doMethod(params) + else + proto.doResponse(params) + end + end) end) return pub diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua index 4f245517..cf1eb955 100644 --- a/server-beta/src/pub/pub.lua +++ b/server-beta/src/pub/pub.lua @@ -1,6 +1,7 @@ local thread = require 'bee.thread' local utility = require 'utility' local task = require 'task' +local timer = require 'timer' local errLog = thread.channel 'errlog' local type = type @@ -97,7 +98,7 @@ function m.popReport(brave, name, params) log.warn(('Brave pushed unknown report: # %d => %q'):format(brave.id, name)) return end - abil(params, brave) + xpcall(abil, log.error, params, brave) end --- 发布任务(异步) @@ -210,7 +211,6 @@ function m.recieve() else m.popTask(brave, id, result) end - task.sleep(0) ::CONTINUE:: end end @@ -227,12 +227,9 @@ function m.checkDead() end function m.listen() - task.create(function () - while true do - m.checkDead() - m.recieve() - task.sleep(0) - end + timer.loop(0.001, function () + m.checkDead() + m.recieve() end) end |