summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua27
1 files changed, 16 insertions, 11 deletions
diff --git a/main.lua b/main.lua
index f1cd109..5e1f26a 100644
--- a/main.lua
+++ b/main.lua
@@ -1,13 +1,15 @@
-_require = require
-require = function(name)
- return _require("jin-modules." .. name)
-end
+-- _require = require
+-- require = function(name)
+-- return _require("jin-modules." .. name)
+-- end
local jnet = require("jnet")
-local log = require("loghelper")
+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
@@ -15,7 +17,7 @@ local socket = nil
jin.core.onLoad = function()
---- 网络测试
jin.net.init()
- socket = jin.net.Socket("TCP", 8807)
+ socket = jin.net.newSocket("TCP", 8807)
local Skill = {
id = jnet.DataType.INT,
damage = jnet.DataType.FLOAT,
@@ -28,7 +30,7 @@ jin.core.onLoad = function()
-- }
cd = jnet.DataType.BOOL
}
- local buf = jin.net.Buffer(0)
+ local buf = jin.net.newBuffer(0)
local mySkill = {
id = 12,
name = "Hell fire!!!",
@@ -41,11 +43,14 @@ jin.core.onLoad = function()
-- }
cd = true
}
+ local len = buf:append("Skill")
jnet.serialize(mySkill, buf)
- local msg = jnet.deserialize(Skill, buf, 0)
- print(msg.name)
+ local msgName = buf:grabString(0)
+ log.error(msgName)
+ local msg = jnet.deserialize(Skill, buf, len)
+ log.info(msg.id)
- thread = jin.thread.Thread("Test", [[
+ thread = jin.thread.newThread("Test", [[
local thread = jin.thread.getThread()
local socket = thread:demand(1)
while true do
@@ -58,7 +63,7 @@ jin.core.onLoad = function()
thread:start()
thread:send(1, socket)
EventMsgCenter.registerMsg(Events.Player_Move, function(msg)
- print(msg)
+ -- print(msg)
end)
timer.every(1.0, function()
log.info(_G["frame"] .. "fps")