使用aegistudio的新网络库获取公告
This commit is contained in:
@@ -926,20 +926,8 @@ do--intro
|
||||
for i=1,8 do
|
||||
sceneTemp.r[i]=rnd(5)
|
||||
end
|
||||
local notice=HTTPrequest("http://47.103.200.40/api/notice")
|
||||
if notice then
|
||||
LOG.print(notice,"message")
|
||||
else
|
||||
LOG.print(text.getNoticeFail,"warn")
|
||||
end
|
||||
local newVersion=HTTPrequest("http://47.103.200.40/api/version_check")
|
||||
if not newVersion then
|
||||
LOG.print(text.getVersionFail,"warn")
|
||||
elseif newVersion~=gameVersion then
|
||||
LOG.print(string.gsub(text.versionIsOld,"$1",newVersion),"warn")
|
||||
else
|
||||
LOG.print(text.versionIsNew,"message")
|
||||
end
|
||||
|
||||
httpRequest(TICK.httpREQ_launch,"http://47.103.200.40/api/game")
|
||||
end
|
||||
|
||||
function mouseDown.intro(x,y,k)
|
||||
@@ -2414,9 +2402,6 @@ do--play
|
||||
end
|
||||
end
|
||||
do--pause
|
||||
local ranks={
|
||||
|
||||
}
|
||||
local rankColor={
|
||||
Z=color.lYellow,
|
||||
S=color.lGrey,
|
||||
|
||||
@@ -74,4 +74,31 @@ function Tick.autoPause(data)
|
||||
return true
|
||||
end
|
||||
end
|
||||
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,"message")
|
||||
if gameVersion==res.version then
|
||||
LOG.print(text.versionIsNew,"message")
|
||||
else
|
||||
LOG.print(string.gsub(text.versionIsOld,"$1",res.version),"warn")
|
||||
end
|
||||
return true
|
||||
else
|
||||
LOG.print("Code error: "..res.code,"warn")
|
||||
return true
|
||||
end
|
||||
elseif err then
|
||||
LOG.print(text.getNoticeFail..":"..err,"warn")
|
||||
return true
|
||||
end
|
||||
data.time=data.time+1
|
||||
if data.time==180 then
|
||||
LOG.print(text.httpTimeout,"message")
|
||||
coroutine.resume(data.selfFunc)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return Tick
|
||||
Reference in New Issue
Block a user