--- Starts all processing in the applicaiton.
local function Begin()
debug_file = io.open(i.debug_file_path, 'a')
LogInfo("Starting client service on " .. os.date("%b %d, %Y %X"))
cq = cqueues.new()
ws = websocket.new_from_uri("ws://" .. conf.server_url .. ":" .. conf.server_port)
cq:wrap(Receive, ws)
cq:wrap(StdioInput)
cq:wrap(DebugInput)
cq:wrap(StatusUpdate, ws, conf.status_period)
local ws_ok, err, errno = ws:connect()
if ws_ok then return true end;
end
local function Run()
repeat
local cq_ok, msg, errno = cq:step()
if cq_ok then
LogInfo("Step")
else
LogInfo("The main cqueue failed to step.")
LogError(errno, msg)
end
until Shutdown == true or cq:empty()
ws:close()
end
if Begin() then
Run()
end
Comments