订正上一个提交漏改的东西
优化debug消息显示格式 调整网络断开提示文本用法
This commit is contained in:
Submodule Zframework updated: 08a65f0b1b...1a44ad2ea1
@@ -110,6 +110,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tooFrequently="Request too frequently",
|
||||||
getNoticeFail="Failed to fetch announcements",
|
getNoticeFail="Failed to fetch announcements",
|
||||||
oldVersion="Version $1 is now available",
|
oldVersion="Version $1 is now available",
|
||||||
needUpdate="Newer version required!",
|
needUpdate="Newer version required!",
|
||||||
@@ -125,8 +126,8 @@ return{
|
|||||||
diffPassword="Passwords don’t match",
|
diffPassword="Passwords don’t match",
|
||||||
checkEmail="A sign up request has been sent.",
|
checkEmail="A sign up request has been sent.",
|
||||||
|
|
||||||
wsFailed="WebSocket connection failed",
|
wsFailed="WebSocket connection failed: $1",
|
||||||
wsClose="WebSocket closed:",
|
wsClose="WebSocket closed: $1",
|
||||||
netTimeout="Connection timed out",
|
netTimeout="Connection timed out",
|
||||||
serverDown="Oops! Server is down",
|
serverDown="Oops! Server is down",
|
||||||
requestFailed="Request failed",
|
requestFailed="Request failed",
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- tooFrequently="Request too frequently",
|
||||||
getNoticeFail="Error al buscar novedades.",
|
getNoticeFail="Error al buscar novedades.",
|
||||||
oldVersion="¡Está disponible la nueva versión $1!",
|
oldVersion="¡Está disponible la nueva versión $1!",
|
||||||
needUpdate="¡Nueva versión requerida!",
|
needUpdate="¡Nueva versión requerida!",
|
||||||
@@ -124,8 +125,8 @@ return{
|
|||||||
diffPassword="Las contraseñas no coinciden",
|
diffPassword="Las contraseñas no coinciden",
|
||||||
checkEmail="Petición de registro enviada con éxito",
|
checkEmail="Petición de registro enviada con éxito",
|
||||||
|
|
||||||
wsFailed="WebSocket conexión fallida",
|
wsFailed="WebSocket conexión fallida: $1",
|
||||||
wsClose="WebSocket cerrado:",
|
wsClose="WebSocket cerrado: $1",
|
||||||
netTimeout="Tiempo de conexión agotado",
|
netTimeout="Tiempo de conexión agotado",
|
||||||
-- serverDown="Oops! Server is down",
|
-- serverDown="Oops! Server is down",
|
||||||
-- requestFailed="Request failed",
|
-- requestFailed="Request failed",
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- tooFrequently="Request too frequently",
|
||||||
getNoticeFail="Echec de l'obtention de la notice",
|
getNoticeFail="Echec de l'obtention de la notice",
|
||||||
oldVersion="La version $1 est disponible !",
|
oldVersion="La version $1 est disponible !",
|
||||||
-- versionNotMatch="Version do not match!",
|
-- versionNotMatch="Version do not match!",
|
||||||
@@ -115,8 +116,8 @@ return{
|
|||||||
diffPassword="Les mots de passe ne se correspondent pas",
|
diffPassword="Les mots de passe ne se correspondent pas",
|
||||||
-- checkEmail="Registration request sent",
|
-- checkEmail="Registration request sent",
|
||||||
|
|
||||||
wsFailed="WebSocket connection échouée",
|
wsFailed="WebSocket connection échouée: $1",
|
||||||
-- wsClose="WebSocket Closed:",
|
-- wsClose="WebSocket Closed: $1",
|
||||||
-- netTimeout="Network connection timeout",
|
-- netTimeout="Network connection timeout",
|
||||||
-- serverDown="Oops! Server is down",
|
-- serverDown="Oops! Server is down",
|
||||||
-- requestFailed="Request failed",
|
-- requestFailed="Request failed",
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- tooFrequently="Request too frequently",
|
||||||
getNoticeFail="Gagal mengambil pengumuman-pengumuman",
|
getNoticeFail="Gagal mengambil pengumuman-pengumuman",
|
||||||
oldVersion="Versi $1 sekarang tersedia",
|
oldVersion="Versi $1 sekarang tersedia",
|
||||||
needUpdate="Butuh versi lebih baru!",
|
needUpdate="Butuh versi lebih baru!",
|
||||||
@@ -126,8 +127,8 @@ return{
|
|||||||
diffPassword="Kata sandi tidak sama",
|
diffPassword="Kata sandi tidak sama",
|
||||||
checkEmail="Permintaan daftar telah terkirim.",
|
checkEmail="Permintaan daftar telah terkirim.",
|
||||||
|
|
||||||
wsFailed="Koneksi websocket gagal",
|
wsFailed="Koneksi websocket gagal: $1",
|
||||||
wsClose="Websocket tertutup:",
|
wsClose="Websocket tertutup: $1",
|
||||||
netTimeout="Koneksi waktu habis",
|
netTimeout="Koneksi waktu habis",
|
||||||
-- serverDown="Oops! Server is down",
|
-- serverDown="Oops! Server is down",
|
||||||
-- requestFailed="Request failed",
|
-- requestFailed="Request failed",
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- tooFrequently="Request too frequently",
|
||||||
getNoticeFail="お知らせ情報を取得できませんでした",
|
getNoticeFail="お知らせ情報を取得できませんでした",
|
||||||
oldVersion="バージョン$1のダウンロードが可能になりました",
|
oldVersion="バージョン$1のダウンロードが可能になりました",
|
||||||
needUpdate="最新バージョンに更新してください",
|
needUpdate="最新バージョンに更新してください",
|
||||||
@@ -126,8 +127,8 @@ return{
|
|||||||
diffPassword="パスワードが一致しません!",
|
diffPassword="パスワードが一致しません!",
|
||||||
checkEmail="Sign Upリクエストを送信しました!",
|
checkEmail="Sign Upリクエストを送信しました!",
|
||||||
|
|
||||||
wsFailed="ウェブソケットとの通信に失敗しました",
|
wsFailed="ウェブソケットとの通信に失敗しました: $1",
|
||||||
wsClose="ウェブソケットとの通信を終了:",
|
wsClose="ウェブソケットとの通信を終了: $1",
|
||||||
netTimeout="接続がタイムアウトしました",
|
netTimeout="接続がタイムアウトしました",
|
||||||
-- serverDown="Oops! Server is down",
|
-- serverDown="Oops! Server is down",
|
||||||
-- requestFailed="Request failed",
|
-- requestFailed="Request failed",
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- tooFrequently="Request too frequently",
|
||||||
getNoticeFail="Não conseguiu ter anúncios",
|
getNoticeFail="Não conseguiu ter anúncios",
|
||||||
oldVersion="Versão $1 esta disponível agora!",
|
oldVersion="Versão $1 esta disponível agora!",
|
||||||
-- versionNotMatch="Version do not match!",
|
-- versionNotMatch="Version do not match!",
|
||||||
@@ -113,8 +114,8 @@ return{
|
|||||||
diffPassword="Senhas não combinam",
|
diffPassword="Senhas não combinam",
|
||||||
-- checkEmail="Registration request sent",
|
-- checkEmail="Registration request sent",
|
||||||
|
|
||||||
wsFailed="WebSocket falha na conexão",
|
wsFailed="WebSocket falha na conexão: $1",
|
||||||
wsClose="WebSocket closed:",
|
wsClose="WebSocket closed: $1",
|
||||||
-- netTimeout="Network connection timeout",
|
-- netTimeout="Network connection timeout",
|
||||||
-- serverDown="Oops! Server is down",
|
-- serverDown="Oops! Server is down",
|
||||||
-- requestFailed="Request failed",
|
-- requestFailed="Request failed",
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tooFrequently="操作太频繁",
|
||||||
getNoticeFail="拉取公告失败",
|
getNoticeFail="拉取公告失败",
|
||||||
oldVersion="最新版本$1可以下载了!",
|
oldVersion="最新版本$1可以下载了!",
|
||||||
needUpdate="请更新游戏!",
|
needUpdate="请更新游戏!",
|
||||||
@@ -125,8 +126,8 @@ return{
|
|||||||
diffPassword="两次密码不一致",
|
diffPassword="两次密码不一致",
|
||||||
checkEmail="请查看邮箱验证码",
|
checkEmail="请查看邮箱验证码",
|
||||||
|
|
||||||
wsFailed="连接失败",
|
wsFailed="连接失败: $1",
|
||||||
wsClose="连接被断开:",
|
wsClose="连接断开: $1",
|
||||||
netTimeout="连接超时",
|
netTimeout="连接超时",
|
||||||
serverDown="唉哟!服务器不在线",
|
serverDown="唉哟!服务器不在线",
|
||||||
requestFailed="请求失败",
|
requestFailed="请求失败",
|
||||||
|
|||||||
@@ -110,9 +110,10 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tooFrequently="Error.requestTooFrequently();",
|
||||||
getNoticeFail="Error.FetchAnnouncement();",
|
getNoticeFail="Error.FetchAnnouncement();",
|
||||||
oldVersion="Version.New($1);",
|
oldVersion="Version.New($1);",
|
||||||
needUpdate="Version.NeedUpdate()",
|
needUpdate="Version.NeedUpdate();",
|
||||||
versionNotMatch="Version.NotMatch();",
|
versionNotMatch="Version.NotMatch();",
|
||||||
notFinished="ComingSoon();",
|
notFinished="ComingSoon();",
|
||||||
|
|
||||||
@@ -125,8 +126,8 @@ return{
|
|||||||
diffPassword="Error.DiffPassword();",
|
diffPassword="Error.DiffPassword();",
|
||||||
checkEmail="register.RequestSent=true",
|
checkEmail="register.RequestSent=true",
|
||||||
|
|
||||||
wsFailed="Error.Websocket.Failed();",
|
wsFailed="Error.Websocket.Failed=$1",
|
||||||
wsClose="Error.Websocket.Close=",
|
wsClose="Error.Websocket.Close=$1",
|
||||||
netTimeout="Error.ConnectTimeOut();",
|
netTimeout="Error.ConnectTimeOut();",
|
||||||
serverDown="Error.ServerDown();",
|
serverDown="Error.ServerDown();",
|
||||||
requestFailed="Error.RequestFailed();",
|
requestFailed="Error.RequestFailed();",
|
||||||
@@ -708,12 +709,12 @@ return{
|
|||||||
title="Register.UI",
|
title="Register.UI",
|
||||||
login="Login();",
|
login="Login();",
|
||||||
email="Email=",
|
email="Email=",
|
||||||
send="Send()",
|
send="Send();",
|
||||||
code="V-code=",
|
code="V-code=",
|
||||||
verify="Verify()",
|
verify="Verify();",
|
||||||
password="Password=",
|
password="Password=",
|
||||||
password2="RePassword=",
|
password2="RePassword=",
|
||||||
setPW="SetPassword()",
|
setPW="SetPassword();",
|
||||||
},
|
},
|
||||||
account={
|
account={
|
||||||
title="Account.UI",
|
title="Account.UI",
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ return{
|
|||||||
-- TODO
|
-- TODO
|
||||||
},
|
},
|
||||||
|
|
||||||
|
tooFrequently="操作太頻繁",
|
||||||
getNoticeFail="無法獲取公告",
|
getNoticeFail="無法獲取公告",
|
||||||
oldVersion="版本 $1 現已推出",
|
oldVersion="版本 $1 現已推出",
|
||||||
needUpdate="請更新遊戲!",
|
needUpdate="請更新遊戲!",
|
||||||
@@ -125,8 +126,8 @@ return{
|
|||||||
diffPassword="密碼不匹配",
|
diffPassword="密碼不匹配",
|
||||||
checkEmail="已發送註冊請求",
|
checkEmail="已發送註冊請求",
|
||||||
|
|
||||||
wsFailed="連接失敗",
|
wsFailed="連接失敗: $1",
|
||||||
wsClose="連接斷開:",
|
wsClose="連接斷開: $1",
|
||||||
netTimeout="連接超時",
|
netTimeout="連接超時",
|
||||||
serverDown="哎唷!服務器不在线",
|
serverDown="哎唷!服務器不在线",
|
||||||
requestFailed="請求失敗",
|
requestFailed="請求失敗",
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ local NET={
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function NET.connectLost()
|
||||||
|
while SCN.stack[#SCN.stack-1]~='main' and #SCN.stack>0 do SCN.pop() end
|
||||||
|
SCN.back()
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------<NEW HTTP API>
|
--------------------------<NEW HTTP API>
|
||||||
local availableErrorTextType={info=1,warn=1,error=1}
|
local availableErrorTextType={info=1,warn=1,error=1}
|
||||||
@@ -334,9 +338,10 @@ local actMap={
|
|||||||
} for k,v in next,actMap do actMap[v]=k end
|
} for k,v in next,actMap do actMap[v]=k end
|
||||||
|
|
||||||
local function wsSend(act,data)
|
local function wsSend(act,data)
|
||||||
-- print("SEND ACT: "..act)
|
-- print(("Send: $1 -->"):repD(act))
|
||||||
|
-- print(("Send: $1 -->"):repD(act)) print(TABLE.dump(data),"\n")
|
||||||
WS.send('game',JSON.encode{
|
WS.send('game',JSON.encode{
|
||||||
action=act,
|
action=assert(act),
|
||||||
data=data,
|
data=data,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -359,13 +364,8 @@ function NET.room_chat(msg,rid)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function NET.room_create(roomName,description,capacity,roomType,roomData,password)
|
function NET.room_create(roomName,description,capacity,roomType,roomData,password)
|
||||||
if not TASK.lock('createRoom',6) then return end
|
if not TASK.lock('createRoom',10) then MES.new('warn',text.tooFrequently) return end
|
||||||
WAIT{
|
WAIT{timeout=12}
|
||||||
quit=function()
|
|
||||||
TASK.unlock('createRoom')
|
|
||||||
end,
|
|
||||||
timeout=1e99,
|
|
||||||
}
|
|
||||||
wsSend(actMap.room_create,{
|
wsSend(actMap.room_create,{
|
||||||
capacity=capacity,
|
capacity=capacity,
|
||||||
info={
|
info={
|
||||||
@@ -404,10 +404,8 @@ function NET.room_enter(rid,password)
|
|||||||
if not TASK.lock('enterRoom',6) then return end
|
if not TASK.lock('enterRoom',6) then return end
|
||||||
SFX.play('reach',.6)
|
SFX.play('reach',.6)
|
||||||
wsSend(actMap.room_enter,{
|
wsSend(actMap.room_enter,{
|
||||||
data={
|
roomId=rid,
|
||||||
roomId=rid,
|
password=password,
|
||||||
password=password,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
function NET.room_kick(pid,rid)
|
function NET.room_kick(pid,rid)
|
||||||
@@ -421,14 +419,14 @@ function NET.room_leave()
|
|||||||
end
|
end
|
||||||
function NET.room_fetch()
|
function NET.room_fetch()
|
||||||
if not TASK.lock('fetchRoom',3) then return end
|
if not TASK.lock('fetchRoom',3) then return end
|
||||||
wsSend(actMap.room_lock,{
|
wsSend(actMap.room_fetch,{
|
||||||
pageIndex=0,
|
pageIndex=0,
|
||||||
pageSize=26,
|
pageSize=26,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
function NET.room_setPW(pw,rid)
|
function NET.room_setPW(pw,rid)
|
||||||
if not TASK.lock('setRoomPW',2) then return end
|
if not TASK.lock('setRoomPW',2) then return end
|
||||||
wsSend(actMap.room_lock,{
|
wsSend(actMap.room_setPW,{
|
||||||
password=pw,
|
password=pw,
|
||||||
roomId=rid,-- Admin
|
roomId=rid,-- Admin
|
||||||
})
|
})
|
||||||
@@ -552,22 +550,21 @@ function NET.ws_update()
|
|||||||
elseif op=='pong' then
|
elseif op=='pong' then
|
||||||
elseif op=='close' then
|
elseif op=='close' then
|
||||||
local res=JSON.decode(msg)
|
local res=JSON.decode(msg)
|
||||||
MES.new('info',("$1 $2"):repD(text.wsClose,res and res.message or msg))
|
MES.new('info',text.wsClose:repD(res and res.message or msg))
|
||||||
if res and res.message then LOG(res.message) end
|
if res and res.message then LOG(res.message) end
|
||||||
TEST.yieldUntilNextScene()
|
TEST.yieldUntilNextScene()
|
||||||
while SCN.stack[#SCN.stack-1]~='main' do SCN.pop() end
|
NET.connectLost()
|
||||||
SCN.back()
|
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
local body=JSON.decode(msg)
|
local body=JSON.decode(msg)
|
||||||
if body then
|
if body then
|
||||||
-- print(("RECV ACT: $1 ($2)"):repD(body.action,body.type))
|
-- print(("Recv: <-- $1 ($2)"):repD(body.action,body.type))
|
||||||
-- print(TABLE.dump(body))
|
-- print(("Recv: <-- $1 ($2)"):repD(body.action,body.type)) print(TABLE.dump(body),"\n")
|
||||||
if body.type=='Failed' then
|
if body.type=='Failed' then
|
||||||
parseError(body.message~=nil and body.message or msg)
|
parseError(body.message~=nil and body.message or msg)
|
||||||
else
|
else
|
||||||
local f=NET.wsCallBack[actMap[body.action]]
|
local f=NET.wsCallBack[actMap[body.action]]
|
||||||
if f then f(body) else print("Wrong action number: "..body.action) end
|
if f then f(body) end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
MES.new('warn',"Wrong json: "..msg,5)
|
MES.new('warn',"Wrong json: "..msg,5)
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ function scene.keyDown(key,isRep)
|
|||||||
elseif key=='return' then
|
elseif key=='return' then
|
||||||
local mes=STRING.trim(inputBox:getText())
|
local mes=STRING.trim(inputBox:getText())
|
||||||
if not inputBox.hide and #mes>0 then
|
if not inputBox.hide and #mes>0 then
|
||||||
if NET.room.chat(mes) then
|
if NET.room_chat(mes) then
|
||||||
inputBox:clear()
|
inputBox:clear()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function scene.keyDown(key)
|
|||||||
local R=roomList:getSel()
|
local R=roomList:getSel()
|
||||||
if R and not TASK.getLock('fetchRoom') then
|
if R and not TASK.getLock('fetchRoom') then
|
||||||
if R.info.version==VERSION.room then
|
if R.info.version==VERSION.room then
|
||||||
NET.room.enter(R.roomId,passwordBox.value)
|
NET.room_enter(R.roomId,passwordBox.value)
|
||||||
else
|
else
|
||||||
MES.new('error',text.versionNotMatch)
|
MES.new('error',text.versionNotMatch)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user