diff options
Diffstat (limited to 'server-beta/src/service.lua')
-rw-r--r-- | server-beta/src/service.lua | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/server-beta/src/service.lua b/server-beta/src/service.lua index 0aaf5a23..639e2ae2 100644 --- a/server-beta/src/service.lua +++ b/server-beta/src/service.lua @@ -3,26 +3,40 @@ local subprocess = require 'bee.subprocess' local thread = require 'bee.thread' local task = require 'task' local utility = require 'utility' +local timer = require 'timer' local m = {} m.type = 'service' -function m:listenProto() +function m.listenProto() subprocess.filemode(io.stdin, 'b') subprocess.filemode(io.stdout, 'b') io.stdin:setvbuf 'no' io.stdout:setvbuf 'no' - coroutine.wrap(function () + task.create(function () while true do - local proto = client:task('loadProto') + local proto = client.task('loadProto') log.debug('proto:', utility.dump(proto)) end end) end -function m:start() - client:recruitBraves(4) - self:listenProto() +function m.startTimer() + local last = os.clock() + while true do + thread.sleep(0.01) + local current = os.clock() + local delta = current - last + last = current + m.update(delta) + end +end + +function m.start() + client.recruitBraves(4) + m.listenProto() + + m.startTimer() end return m |