aboutsummaryrefslogtreecommitdiff
path: root/bin/client/main.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-08-14 16:14:32 +0800
committerchai <chaifix@163.com>2018-08-14 16:14:32 +0800
commit57efa331c7ddc247c9b14dc19d4d98afbeb4e3b4 (patch)
tree1ebba4cd5b97a771d2f35e708ceda7193b904516 /bin/client/main.lua
parent0d26ed3a45f53fdbd7731b5f2a4d88edef201e44 (diff)
*update
Diffstat (limited to 'bin/client/main.lua')
-rw-r--r--bin/client/main.lua28
1 files changed, 11 insertions, 17 deletions
diff --git a/bin/client/main.lua b/bin/client/main.lua
index 5d10e6a..9c176f8 100644
--- a/bin/client/main.lua
+++ b/bin/client/main.lua
@@ -11,14 +11,13 @@ while true do
thread:send(2, buf)
end
]]
-
jin.core.onLoad = function()
- -- jin.net.init()
- -- socket = jin.net.Socket("TCP", "127.0.0.1", 8809)
+ jin.net.init()
+ socket = jin.net.Socket("TCP", "127.0.0.1", 8803)
- -- thread = jin.thread.Thread("asynReceive", asynReceive)
- -- thread:start()
- -- thread:send(1, socket)
+ thread = jin.thread.Thread("asynReceive", asynReceive)
+ thread:start()
+ thread:send(1, socket)
end
jin.core.onEvent = function(e)
@@ -32,18 +31,13 @@ end
local x = 0
local y = 0
jin.core.onUpdate = function(dt)
- -- if thread:receive(2) then
- -- local buf = thread:fetch(2)
- -- x, xl = buf:grabFloat(0)
- -- y, yl = buf:grabFloat(xl)
- -- end
-
- -- local buf = jin.net.Buffer(0)
- -- buf:append(x)
- -- buf:append(y)
- -- thread:send(3, buf)
+ if thread:receive(2) then
+ local buf = thread:fetch(2)
+ x, xl = buf:grabFloat(0)
+ y, yl = buf:grabFloat(xl)
+ end
end
jin.core.onDraw = function()
jin.graphics.circle("fill", x, y, 12)
-end \ No newline at end of file
+end