Advertisement
lvs

Lua udp server

lvs
Sep 16th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1. local udp = socket.udp()
  2. udp:setsockname('127.0.0.1', 5000)
  3. udp:settimeout(0.001)
  4. local char, ip, port
  5. timer.performWithDelay(200, function ()
  6.         char, ip, port = udp:receivefrom()
  7.         if char then
  8.             local scene = storyboard.getScene(storyboard.getCurrentSceneName())
  9.             if type(scene.keyboardPressed) == 'function' then
  10.                 scene:keyboardPressed(char)
  11.             end
  12.         end
  13.     end, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement