diff options
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 94 |
1 files changed, 0 insertions, 94 deletions
@@ -1,94 +0,0 @@ --- _require = require --- require = function(name) --- return _require("jin-modules." .. name) --- end -local jnet = require("jnet") -local log = require("log") -log.dateFormat("") -log.strict(log.LEVEL.INFO) -local EventMsgCenter = require("EventMsgCenter.EventMsgCenter") -local Events = require("EventMsgCenter.Events") -local timer = require("timer.timer") -require("gameloop") -_G["frame"] = 0 - -local thread = nil -local socket = nil -jin.core.onLoad = function() ----- 网络测试 - jin.net.init() - socket = jin.net.newSocket("TCP", 8807) - local Skill = { - id = jnet.DataType.INT, - damage = jnet.DataType.FLOAT, - name = jnet.DataType.STRING, - description = jnet.DataType.STRING, - -- bonus = { - -- damage = FLOAT, - -- range = FLOAT, - -- cd = BOOL - -- } - cd = jnet.DataType.BOOL - } - local buf = jin.net.newBuffer(0) - local mySkill = { - id = 12, - name = "Hell fire!!!", - damage = 3.4, - description = "1234", - -- bonus = { - -- damage = FLOAT, - -- range = FLOAT, - -- cd = BOOL - -- } - cd = true - } - local len = buf:append("Skill") - jnet.serialize(mySkill, buf) - local msgName = buf:grabString(0) - log.error(msgName) - local msg = jnet.deserialize(Skill, buf, len) - log.info(msg.id) - - thread = jin.thread.newThread("Test", [[ - local thread = jin.thread.getThread() - local socket = thread:demand(1) - while true do - local client = socket:accept() - local buf = client:receive() - local str = buf:grabString(0) - print(str) - end - ]]) - thread:start() - thread:send(1, socket) - EventMsgCenter.registerMsg(Events.Player_Move, function(msg) - -- print(msg) - end) - timer.every(1.0, function() - log.info(_G["frame"] .. "fps") - -- EventMsgCenter.sendMsg(Events.Player_Move, _G["frame"]) - _G["frame"] = 0 - end) - timer.after(4.0, function() - EventMsgCenter.unregisterAllMsgByEvent(Events.Player_Move) - end) -end - -jin.core.onEvent = function(e) - if e.type == "quit" then - jin.core.stop() elseif e.type == "keydown" then - if e.key == "Escape" then - jin.core.stop() - end - end -end - -jin.core.onUpdate = function(dt) - _G["frame"] = _G["frame"] + 1 - timer.update(dt) -end - -jin.core.onDraw = function() - -end
\ No newline at end of file |