Advertisement
_dinsdale

Untitled

Oct 5th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. --- Starts all processing in the applicaiton.
  2. local function Begin()
  3. debug_file = io.open(i.debug_file_path, 'a')
  4.  
  5. LogInfo("Starting client service on " .. os.date("%b %d, %Y %X"))
  6.  
  7. cq = cqueues.new()
  8. ws = websocket.new_from_uri("ws://" .. conf.server_url .. ":" .. conf.server_port)
  9.  
  10. cq:wrap(Receive, ws)
  11. cq:wrap(StdioInput)
  12. cq:wrap(DebugInput)
  13. cq:wrap(StatusUpdate, ws, conf.status_period)
  14.  
  15. local ws_ok, err, errno = ws:connect()
  16. if ws_ok then return true end;
  17. end
  18.  
  19. local function Run()
  20. repeat
  21. local cq_ok, msg, errno = cq:step()
  22. if cq_ok then
  23. LogInfo("Step")
  24. else
  25.  
  26. LogInfo("The main cqueue failed to step.")
  27. LogError(errno, msg)
  28. end
  29. until Shutdown == true or cq:empty()
  30. ws:close()
  31. end
  32.  
  33.  
  34. if Begin() then
  35. Run()
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement