From e02ead0fa3d86e4c9ecb26ce796bfeb20e751934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 20 Sep 2019 11:46:43 +0800 Subject: =?UTF-8?q?=E6=B3=A8=E5=86=8Cmethod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/service/service.lua | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 server-beta/src/service/service.lua (limited to 'server-beta/src/service/service.lua') diff --git a/server-beta/src/service/service.lua b/server-beta/src/service/service.lua new file mode 100644 index 00000000..2f7e31b8 --- /dev/null +++ b/server-beta/src/service/service.lua @@ -0,0 +1,40 @@ +local pub = require 'pub' +local thread = require 'bee.thread' +local task = require 'task' +local timer = require 'timer' +local proto = require 'service.proto' + +local m = {} +m.type = 'service' + +function m.listenPub() + task.create(function () + while true do + pub.checkDead() + pub.recieve() + task.sleep(0) + end + end) +end + +function m.startTimer() + local last = os.clock() + while true do + thread.sleep(0.001) + local current = os.clock() + local delta = current - last + last = current + timer.update(delta) + end +end + +function m.start() + pub.recruitBraves(4) + task.setErrorHandle(log.error) + proto.listen() + m.listenPub() + + m.startTimer() +end + +return m -- cgit v1.2.3