修正分支合并
This commit is contained in:
@@ -45,13 +45,6 @@ function TASK.removeTask_data(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function TASK.checkTask_code(code)
|
|
||||||
for i=#tasks,1,-1 do
|
|
||||||
if tasks[i].code==code then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function TASK.clear()
|
function TASK.clear()
|
||||||
local i=#tasks
|
local i=#tasks
|
||||||
while i>0 do
|
while i>0 do
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ do--urlencode
|
|||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
do--httpRequest
|
do--httpRequest & wsConnect
|
||||||
client=LOADLIB("NETlib")
|
client=LOADLIB("NETlib")
|
||||||
httpRequest=
|
httpRequest=
|
||||||
client and function(tick,path,method,header,body)
|
client and function(tick,path,method,header,body)
|
||||||
|
|||||||
@@ -809,28 +809,26 @@ function WIDGET.lnk_swapScene(t,s) return function() SCN.swapTo(t,s) end end
|
|||||||
function WIDGET.lnk_goNetgame()
|
function WIDGET.lnk_goNetgame()
|
||||||
if LOGIN then
|
if LOGIN then
|
||||||
if ACCOUNT.access_token then
|
if ACCOUNT.access_token then
|
||||||
local res=json.encode{
|
|
||||||
email=ACCOUNT.email,
|
|
||||||
access_token=ACCOUNT.access_token,
|
|
||||||
}
|
|
||||||
httpRequest(
|
httpRequest(
|
||||||
TICK.httpREQ_checkAccessToken,
|
TICK.httpREQ_checkAccessToken,
|
||||||
PATH.api..PATH.access,
|
PATH.api..PATH.access,
|
||||||
"GET",
|
"GET",
|
||||||
{["Content-Type"]="application/json"},
|
{["Content-Type"]="application/json"},
|
||||||
res
|
json.encode{
|
||||||
|
email=ACCOUNT.email,
|
||||||
|
access_token=ACCOUNT.access_token,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
local payload=json.encode{
|
|
||||||
email=ACCOUNT.email,
|
|
||||||
auth_token=ACCOUNT.auth_token,
|
|
||||||
}
|
|
||||||
httpRequest(
|
httpRequest(
|
||||||
TICK.httpREQ_getAccessToken,
|
TICK.httpREQ_getAccessToken,
|
||||||
PATH.api..PATH.access,
|
PATH.api..PATH.access,
|
||||||
"POST",
|
"POST",
|
||||||
{["Content-Type"]="application/json"},
|
{["Content-Type"]="application/json"},
|
||||||
payload
|
json.encode{
|
||||||
|
email=ACCOUNT.email,
|
||||||
|
auth_token=ACCOUNT.auth_token,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ SETTING={
|
|||||||
}
|
}
|
||||||
|
|
||||||
STAT={
|
STAT={
|
||||||
version=VERSION_NAME,
|
version=VERSION_CODE,
|
||||||
run=0,game=0,time=0,frame=0,
|
run=0,game=0,time=0,frame=0,
|
||||||
key=0,rotate=0,hold=0,
|
key=0,rotate=0,hold=0,
|
||||||
extraPiece=0,finesseRate=0,
|
extraPiece=0,finesseRate=0,
|
||||||
|
|||||||
@@ -1,32 +1,40 @@
|
|||||||
local function socketWrite(message)
|
local function socketWrite(message)
|
||||||
if not WSCONN then
|
if WSCONN then
|
||||||
|
local writeErr=client.write(WSCONN,message)
|
||||||
|
if writeErr then print(writeErr,"warn")end
|
||||||
|
else
|
||||||
LOG.print("尚未连接到服务器","warn")
|
LOG.print("尚未连接到服务器","warn")
|
||||||
return
|
|
||||||
end
|
end
|
||||||
local writeErr = client.write(WSCONN, message)
|
|
||||||
if writeErr then
|
|
||||||
print(writeErr, "warn")
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function send()
|
local function sendMessage()
|
||||||
local W=WIDGET.active.text
|
local W=WIDGET.active.text
|
||||||
socketWrite(W.value)
|
if #W.value>0 then
|
||||||
W.value=""
|
socketWrite(W.value)
|
||||||
|
W.value=""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function sceneInit.chat()
|
function sceneInit.chat()
|
||||||
BG.set("none")
|
BG.set("none")
|
||||||
wsConnect(
|
wsConnect(
|
||||||
TICK.wsCONN_connect,
|
TICK.wsCONN_connect,
|
||||||
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token),
|
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token)
|
||||||
{}
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function keyDown.chat(k)
|
||||||
|
if k=="return"then
|
||||||
|
sendMessage()
|
||||||
|
elseif k=="escape"then
|
||||||
|
SCN.back()
|
||||||
|
else
|
||||||
|
WIDGET.keyPressed(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
WIDGET.init("chat",{
|
WIDGET.init("chat",{
|
||||||
WIDGET.newTextBox{name="text", x=40, y=500,w=980,h=180,font=40},
|
WIDGET.newTextBox{name="text", x=40, y=500,w=980,h=180,font=40},
|
||||||
WIDGET.newButton{name="send", x=1140, y=540,w=170,h=80,font=40,code=send},
|
WIDGET.newButton{name="send", x=1140, y=540,w=170,h=80,font=40,code=sendMessage},
|
||||||
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK},
|
WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK},
|
||||||
})
|
})
|
||||||
@@ -118,19 +118,16 @@ function Tmr.load()
|
|||||||
VOC.play("welcome_voc")
|
VOC.play("welcome_voc")
|
||||||
httpRequest(TICK.httpREQ_launch,PATH.api..PATH.appInfo)
|
httpRequest(TICK.httpREQ_launch,PATH.api..PATH.appInfo)
|
||||||
if ACCOUNT.auth_token and ACCOUNT.email then
|
if ACCOUNT.auth_token and ACCOUNT.email then
|
||||||
local res=json.encode{
|
httpRequest(
|
||||||
email=ACCOUNT.email,
|
TICK.httpREQ_autoLogin,
|
||||||
auth_token=ACCOUNT.auth_token,
|
PATH.api..PATH.auth,
|
||||||
}
|
"GET",
|
||||||
if res then
|
{["Content-Type"]="application/json"},
|
||||||
httpRequest(
|
json.encode{
|
||||||
TICK.httpREQ_autoLogin,
|
email=ACCOUNT.email,
|
||||||
PATH.api..PATH.auth,
|
auth_token=ACCOUNT.auth_token,
|
||||||
"GET",
|
}
|
||||||
{["Content-Type"]="application/json"},
|
)
|
||||||
res
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if S.tar then
|
if S.tar then
|
||||||
|
|||||||
@@ -7,19 +7,16 @@ function keyDown.login(key)
|
|||||||
elseif #password==0 then
|
elseif #password==0 then
|
||||||
LOG.print(text.noPassword)return
|
LOG.print(text.noPassword)return
|
||||||
end
|
end
|
||||||
local res=json.encode{
|
httpRequest(
|
||||||
email=email,
|
TICK.httpREQ_newLogin,
|
||||||
password=password,
|
PATH.api..PATH.auth,
|
||||||
}
|
"GET",
|
||||||
if res then
|
{["Content-Type"]="application/json"},
|
||||||
httpRequest(
|
json.encode{
|
||||||
TICK.httpREQ_newLogin,
|
email=email,
|
||||||
PATH.api..PATH.auth,
|
password=password,
|
||||||
"GET",
|
}
|
||||||
{["Content-Type"]="application/json"},
|
)
|
||||||
res
|
|
||||||
)
|
|
||||||
end
|
|
||||||
elseif key=="escape"then
|
elseif key=="escape"then
|
||||||
SCN.back()
|
SCN.back()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -13,20 +13,17 @@ function keyDown.register(key)
|
|||||||
elseif password~=password2 then
|
elseif password~=password2 then
|
||||||
LOG.print(text.diffPassword)return
|
LOG.print(text.diffPassword)return
|
||||||
end
|
end
|
||||||
local res=json.encode{
|
httpRequest(
|
||||||
username=username,
|
TICK.httpREQ_register,
|
||||||
email=email,
|
PATH.api..PATH.auth,
|
||||||
password=password,
|
"POST",
|
||||||
}
|
{["Content-Type"]="application/json"},
|
||||||
if res then
|
json.encode{
|
||||||
httpRequest(
|
username=username,
|
||||||
TICK.httpREQ_register,
|
email=email,
|
||||||
PATH.api..PATH.auth,
|
password=password,
|
||||||
"POST",
|
}
|
||||||
{["Content-Type"]="application/json"},
|
)
|
||||||
res
|
|
||||||
)
|
|
||||||
end
|
|
||||||
elseif key=="escape"then
|
elseif key=="escape"then
|
||||||
SCN.back()
|
SCN.back()
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -146,16 +146,15 @@ function Tick.httpREQ_newLogin(data)
|
|||||||
ACCOUNT.auth_token=res.auth_token
|
ACCOUNT.auth_token=res.auth_token
|
||||||
FILE.save(ACCOUNT,"account","")
|
FILE.save(ACCOUNT,"account","")
|
||||||
|
|
||||||
local payload=json.encode{
|
|
||||||
email=ACCOUNT.email,
|
|
||||||
auth_token=ACCOUNT.auth_token,
|
|
||||||
}
|
|
||||||
httpRequest(
|
httpRequest(
|
||||||
TICK.httpREQ_getAccessToken,
|
TICK.httpREQ_getAccessToken,
|
||||||
PATH.api..PATH.access,
|
PATH.api..PATH.access,
|
||||||
"POST",
|
"POST",
|
||||||
{["Content-Type"]="application/json"},
|
{["Content-Type"]="application/json"},
|
||||||
payload
|
json.encode{
|
||||||
|
email=ACCOUNT.email,
|
||||||
|
auth_token=ACCOUNT.auth_token,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
|
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
|
||||||
@@ -199,16 +198,15 @@ function Tick.httpREQ_checkAccessToken(data)
|
|||||||
SCN.pop()
|
SCN.pop()
|
||||||
SCN.go("netgame")
|
SCN.go("netgame")
|
||||||
elseif response.code==403 or response.code==401 then
|
elseif response.code==403 or response.code==401 then
|
||||||
local payload=json.encode{
|
|
||||||
email=ACCOUNT.email,
|
|
||||||
auth_token=ACCOUNT.auth_token,
|
|
||||||
}
|
|
||||||
httpRequest(
|
httpRequest(
|
||||||
TICK.httpREQ_getAccessToken,
|
TICK.httpREQ_getAccessToken,
|
||||||
PATH.api..PATH.access,
|
PATH.api..PATH.access,
|
||||||
"POST",
|
"POST",
|
||||||
{["Content-Type"]="application/json"},
|
{["Content-Type"]="application/json"},
|
||||||
payload
|
json.encode{
|
||||||
|
email=ACCOUNT.email,
|
||||||
|
auth_token=ACCOUNT.auth_token,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
local err=json.decode(response.body)
|
local err=json.decode(response.body)
|
||||||
@@ -264,7 +262,7 @@ function Tick.wsCONN_connect(data)
|
|||||||
local wsconn,connErr=client.poll(data.wsconntask)
|
local wsconn,connErr=client.poll(data.wsconntask)
|
||||||
if wsconn then
|
if wsconn then
|
||||||
WSCONN = wsconn
|
WSCONN = wsconn
|
||||||
TASK.new(Tick.wsCONN_read,{net=true})
|
TASK.new(Tick.wsCONN_read)
|
||||||
return true
|
return true
|
||||||
elseif connErr then
|
elseif connErr then
|
||||||
LOG.print(text.wsFailed..": "..connErr,"warn")
|
LOG.print(text.wsFailed..": "..connErr,"warn")
|
||||||
@@ -273,10 +271,7 @@ function Tick.wsCONN_connect(data)
|
|||||||
end
|
end
|
||||||
return checkTimeout(data,360)
|
return checkTimeout(data,360)
|
||||||
end
|
end
|
||||||
function Tick.wsCONN_read(data)
|
function Tick.wsCONN_read()
|
||||||
if not data.net then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
local messages,readErr=client.read(WSCONN)
|
local messages,readErr=client.read(WSCONN)
|
||||||
if messages then
|
if messages then
|
||||||
if messages[1] then
|
if messages[1] then
|
||||||
|
|||||||
Reference in New Issue
Block a user