Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local debug_channel = love.thread.getChannel("debug_channel")
- local debug_command = love.thread.getChannel("debug_command")
- local log
- log = function(...)
- local t = ""
- local _list_0 = {
- ...
- }
- for _index_0 = 1, #_list_0 do
- local i = _list_0[_index_0]
- t = t .. " " .. tostring(i)
- end
- print("[" .. os.date() .. "]", t)
- return debug_channel:push(t:sub(2))
- end
- local socket = require("socket")
- local udp = socket.udp()
- log("cat23")
- udp:setsockname("*", 48655)
- udp:settimeout(10)
- local clients = { }
- local a = debug_command:peek()
- log(a)
- while not a do
- a = debug_command:peek()
- log(a, "test")
- log(debug_channel:getCount())
- log("clients:", #clients)
- local data, ip, port = udp:receivefrom()
- if data then
- local com = csv(data)
- if com[1] == "login" then
- udp:sendto("ok", ip, port)
- local id = #clients + 1
- clients[id] = {
- ip,
- port
- }
- clients[ip] = id
- log("login cid:", id)
- end
- if com[1] == "move" then
- log("move cid:", clients[ip])
- for _index_0 = 1, #clients do
- local cl = clients[_index_0]
- if ip ~= cl[1] then
- udp:sendto(data, cl[1], cl[2])
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement