整理tick函数,大多数不再是全局,而是直接放到使用的场景作为local变量

This commit is contained in:
MrZ626
2020-12-06 02:53:00 +08:00
parent ebd2cce1db
commit bcacee9d6e
7 changed files with 319 additions and 314 deletions

View File

@@ -1,3 +1,30 @@
local function tick_httpREQ_register(task)
local time=0
while true do
coroutine.yield()
local response,request_error=client.poll(task)
if response then
local res=json.decode(response.body)
if res then
if response.code==200 then
LOG.print(text.registerSuccessed..": "..res.message)
else
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
end
end
return
elseif request_error then
LOG.print(text.loginFailed..": "..request_error,"warn")
return
end
time=time+1
if time>360 then
LOG.print(text.httpTimeout,"message")
return
end
end
end
local scene={}
function scene.keyDown(key)
@@ -16,7 +43,7 @@ function scene.keyDown(key)
LOG.print(text.diffPassword)return
end
httpRequest(
TICK.httpREQ_register,
tick_httpREQ_register,
PATH.api..PATH.auth,
"POST",
{["Content-Type"]="application/json"},