魔改json库,最后套一层pcall防止致命错误

This commit is contained in:
MrZ626
2020-10-31 21:25:09 +08:00
parent 5745174a9c
commit 6438f16287
5 changed files with 27 additions and 11 deletions

View File

@@ -78,12 +78,16 @@ function Tick.httpREQ_launch(data)
local res,err=client.poll(data.task)
if res then
if res.code==200 then
res=json.decode(res.body)
LOG.print(res.notice,360,color.sky)
if gameVersion==res.version then
LOG.print(text.versionIsNew,360,color.sky)
err,res=json.decode(res.body)
if res then
LOG.print(res.notice,360,color.sky)
if gameVersion==res.version then
LOG.print(text.versionIsNew,360,color.sky)
else
LOG.print(string.gsub(text.versionIsOld,"$1",res.version),"warn")
end
else
LOG.print(string.gsub(text.versionIsOld,"$1",res.version),"warn")
LOG.print(text.jsonError..": "..err,"warn")
end
else
LOG.print(text.netErrorCode..res.code,"warn")
@@ -103,11 +107,15 @@ function Tick.httpREQ_register(data)
local res,err=client.poll(data.task)
if res then
if res.code==200 then
res=json.decode(res.body)
if res.status then
LOG.print(text.registerSuccessed)
err,res=json.decode(res.body)
if res then
if res.status then
LOG.print(text.registerSuccessed)
else
LOG.print(text.registerFailed..": "..res.msg)
end
else
LOG.print(text.registerFailed..": "..res.msg)
LOG.print(text.jsonError..": "..err,"warn")
end
else
LOG.print(text.netErrorCode..res.code,"warn")