退出前会主动断开一下ws连接

WAIT放到网络相关TASK函数内部(会在第一帧触发,不影响)
可以从语言文件翻译服务器的错误消息并显示了
框架跟进
This commit is contained in:
MrZ_26
2022-10-06 03:16:18 +08:00
parent f8d17b23b6
commit 8e99565a9d
15 changed files with 228 additions and 122 deletions

View File

@@ -228,7 +228,16 @@ do-- Z.setOnFocus
end end
end) end)
end end
Z.setOnQuit(destroyPlayers) Z.setOnBeforeQuit(function()
NET.ws.close()
TASK.new(function()
TEST.yieldT(.26)
love.event.quit()
end)
end)
Z.setOnQuit(function()
destroyPlayers()
end)
-- Load settings and statistics -- Load settings and statistics
if if

View File

@@ -104,6 +104,12 @@ return{
dictNote="==Copied from TetroDictionary==", dictNote="==Copied from TetroDictionary==",
Techrater={-- Server's warn/error messages
-- TODO
},
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!",
@@ -138,6 +144,8 @@ return{
chatStart="------Beginning of log------", chatStart="------Beginning of log------",
chatHistory="------New messages below------", chatHistory="------New messages below------",
keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete", keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete",
customBGhelp="Drop image file here to apply custom background", customBGhelp="Drop image file here to apply custom background",
customBGloadFailed="Unsupport image format for custom background", customBGloadFailed="Unsupport image format for custom background",

View File

@@ -103,6 +103,12 @@ return{
dictNote="==Copia de TetroDictionary==", dictNote="==Copia de TetroDictionary==",
Techrater={-- Server's warn/error messages
-- TODO
},
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!",
@@ -137,6 +143,8 @@ return{
chatStart="------Comienzo del historial------", chatStart="------Comienzo del historial------",
chatHistory="------Nuevos mensajes------", chatHistory="------Nuevos mensajes------",
keySettingInstruction="Pulsa la tecla a mapear\nEsc.: Cancelar\nBackspace: Borrar", keySettingInstruction="Pulsa la tecla a mapear\nEsc.: Cancelar\nBackspace: Borrar",
customBGhelp="Suelta una imagen aquí para aplicarla de fondo", customBGhelp="Suelta una imagen aquí para aplicarla de fondo",
customBGloadFailed="Formato de imagen no soportado", customBGloadFailed="Formato de imagen no soportado",

View File

@@ -94,6 +94,12 @@ return{
-- dictNote="==Copied from TetroDictionary==", -- dictNote="==Copied from TetroDictionary==",
Techrater={-- Server's warn/error messages
-- TODO
},
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!",
@@ -128,6 +134,8 @@ return{
chatStart="--------Début des logs--------", chatStart="--------Début des logs--------",
chatHistory="-Nouveaux messages en dessous-", chatHistory="-Nouveaux messages en dessous-",
-- keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete", -- keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete",
-- customBGhelp="Drop image file here to apply custom background", -- customBGhelp="Drop image file here to apply custom background",
-- customBGloadFailed="Unsupport image format for custom background", -- customBGloadFailed="Unsupport image format for custom background",

View File

@@ -105,6 +105,12 @@ return{
dictNote="==Tersalin dari TetroDictionary==", dictNote="==Tersalin dari TetroDictionary==",
Techrater={-- Server's warn/error messages
-- TODO
},
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!",
@@ -139,6 +145,8 @@ return{
chatStart="------Awal percakapan------", chatStart="------Awal percakapan------",
chatHistory="------Pesan-pesan baru di bawah ini------", chatHistory="------Pesan-pesan baru di bawah ini------",
keySettingInstruction="Tekan untuk menghubung tombol ke aksi tertentu\nescape: batal\nbackspace: hapus", keySettingInstruction="Tekan untuk menghubung tombol ke aksi tertentu\nescape: batal\nbackspace: hapus",
customBGhelp="Seret file gambar di sini untuk memasangkan background", customBGhelp="Seret file gambar di sini untuk memasangkan background",
customBGloadFailed="Format file gambar tidak didukung untuk background", customBGloadFailed="Format file gambar tidak didukung untuk background",

View File

@@ -105,6 +105,12 @@ return{
dictNote="==TetroDictionaryからコピーしました==", dictNote="==TetroDictionaryからコピーしました==",
Techrater={-- Server's warn/error messages
-- TODO
},
getNoticeFail="お知らせ情報を取得できませんでした", getNoticeFail="お知らせ情報を取得できませんでした",
oldVersion="バージョン$1のダウンロードが可能になりました", oldVersion="バージョン$1のダウンロードが可能になりました",
needUpdate="最新バージョンに更新してください", needUpdate="最新バージョンに更新してください",
@@ -139,6 +145,8 @@ return{
chatStart="------チャットの先頭------", chatStart="------チャットの先頭------",
chatHistory="------新しいメッセージ------", chatHistory="------新しいメッセージ------",
keySettingInstruction="選択してキーを入力\nEscape: キャンセル\nBackspace: キーを削除", keySettingInstruction="選択してキーを入力\nEscape: キャンセル\nBackspace: キーを削除",
customBGhelp="カスタム背景にする画像ファイルをドロップ", customBGhelp="カスタム背景にする画像ファイルをドロップ",
customBGloadFailed="サポートされていないフォーマットのファイルです", customBGloadFailed="サポートされていないフォーマットのファイルです",

View File

@@ -92,6 +92,12 @@ return{
-- dictNote="==Copied from TetroDictionary==", -- dictNote="==Copied from TetroDictionary==",
Techrater={-- Server's warn/error messages
-- TODO
},
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!",
@@ -126,6 +132,8 @@ return{
chatStart="------Começo do log------", chatStart="------Começo do log------",
chatHistory="------Novas mensagens abaixo------", chatHistory="------Novas mensagens abaixo------",
-- keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete", -- keySettingInstruction="Press to bind key\nescape: cancel\nbackspace: delete",
-- customBGhelp="Drop image file here to apply custom background", -- customBGhelp="Drop image file here to apply custom background",
-- customBGloadFailed="Unsupport image format for custom background", -- customBGloadFailed="Unsupport image format for custom background",

View File

@@ -104,6 +104,12 @@ return{
dictNote="==复制于小z词典==", dictNote="==复制于小z词典==",
Techrater={-- Server's warn/error messages
-- TODO
},
getNoticeFail="拉取公告失败", getNoticeFail="拉取公告失败",
oldVersion="最新版本$1可以下载了", oldVersion="最新版本$1可以下载了",
needUpdate="请更新游戏!", needUpdate="请更新游戏!",
@@ -138,6 +144,8 @@ return{
chatStart="------消息的开头------", chatStart="------消息的开头------",
chatHistory="------以上是历史消息------", chatHistory="------以上是历史消息------",
keySettingInstruction="点击添加键位绑定\nesc取消选中\n退格键清空选中", keySettingInstruction="点击添加键位绑定\nesc取消选中\n退格键清空选中",
customBGhelp="把图片文件拖到这个窗口里使用自定义背景", customBGhelp="把图片文件拖到这个窗口里使用自定义背景",
customBGloadFailed="自定义背景的图片文件格式不支持", customBGloadFailed="自定义背景的图片文件格式不支持",

View File

@@ -104,6 +104,12 @@ return{
dictNote="#!CopySource=Zictionary", dictNote="#!CopySource=Zictionary",
Techrater={-- Server's warn/error messages
-- TODO
},
getNoticeFail="Error.FetchAnnouncement();", getNoticeFail="Error.FetchAnnouncement();",
oldVersion="Version.New($1);", oldVersion="Version.New($1);",
needUpdate="Version.NeedUpdate()", needUpdate="Version.NeedUpdate()",
@@ -138,6 +144,8 @@ return{
chatStart="#!Log.Beginning();", chatStart="#!Log.Beginning();",
chatHistory="#!NewMassagesBelow();", chatHistory="#!NewMassagesBelow();",
keySettingInstruction="Key.Bind(Press);\nKey.Bind.Cancel(Escspe);\nKey.Bind.Delete(Backspace);", keySettingInstruction="Key.Bind(Press);\nKey.Bind.Cancel(Escspe);\nKey.Bind.Delete(Backspace);",
customBGhelp="Ctm.BG(DropHere);", customBGhelp="Ctm.BG(DropHere);",
customBGloadFailed="Error.Ctm.BG(UnsupportFormat);", customBGloadFailed="Error.Ctm.BG(UnsupportFormat);",

View File

@@ -104,6 +104,12 @@ return{
dictNote="==拷貝自小z辭典==", dictNote="==拷貝自小z辭典==",
Techrater={-- Server's warn/error messages
-- TODO
},
getNoticeFail="無法獲取公告", getNoticeFail="無法獲取公告",
oldVersion="版本 $1 現已推出", oldVersion="版本 $1 現已推出",
needUpdate="請更新遊戲!", needUpdate="請更新遊戲!",
@@ -138,6 +144,8 @@ return{
chatStart="------訊息開始------", chatStart="------訊息開始------",
chatHistory="------以上為歷史訊息------", chatHistory="------以上為歷史訊息------",
keySettingInstruction="點擊來設置鍵位\n按esc來取消選中\n按退格鍵來清除選中", keySettingInstruction="點擊來設置鍵位\n按esc來取消選中\n按退格鍵來清除選中",
customBGhelp="把圖片檔案拖到這個視窗裏使用自定義背景", customBGhelp="把圖片檔案拖到這個視窗裏使用自定義背景",
customBGloadFailed="自定義背景的圖片檔案格式不支持", customBGloadFailed="自定義背景的圖片檔案格式不支持",

View File

@@ -29,14 +29,54 @@ local NET={
--------------------------<NEW HTTP API> --------------------------<NEW HTTP API>
local availableErrorTextType={info=1,warn=1,error=1}
local function parseError(pathStr)
LOG(pathStr)
if type(pathStr)~='string' then
MES.new('error',"<"..tostring(pathStr)..">",5)
elseif pathStr:find("[^0-9a-z.]") then
MES.new('error',"["..pathStr.."]",5)
else
local mesPath=STRING.split(pathStr,'.')
if mesPath[1]~='Techrater' then
MES.new('error',"["..pathStr.."]",5)
return
end
local curText=text.Techrater
for i=2,#mesPath do
if type(curText)~='table' then break end
curText=curText[mesPath[i]]
end
if type(curText)=='table' then
if availableErrorTextType[curText[1]] and type(curText[2])=='string' and type(curText[3])=='number' then
MES.new(curText[1],curText[2],math.min(curText[3],5))
else
MES.new('error',"["..pathStr.."]",5)
end
elseif type(curText)=='string' then
if #curText>0 then
MES.new('warn',curText,5)
end
else
MES.new('error',"["..pathStr.."]",5)
end
end
end
local function getMsg(request,timeout) local function getMsg(request,timeout)
HTTP(request) HTTP(request)
local totalTime=0 local totalTime=0
while true do while true do
local mes=HTTP.pollMsg(request.pool) local msg=HTTP.pollMsg(request.pool)
if mes then if msg then
if type(mes.body)=='string' and #mes.body>0 then if type(msg.body)=='string' and #msg.body>0 then
return JSON.decode(mes.body) local body=JSON.decode(msg.body)
if body then
if tostring(body.code):sub(1,1)~='2' then
parseError(body.message~=nil and body.message or msg)
end
return body
end
else else
MES.new('info',text.serverDown) MES.new('info',text.serverDown)
return return
@@ -52,6 +92,14 @@ end
function NET.getCode(email) function NET.getCode(email)
if not TASK.lock('getCode') then return end if not TASK.lock('getCode') then return end
TASK.new(function() TASK.new(function()
WAIT{
quit=function()
TASK.unlock('getCode')
HTTP.deletePool('getCode')
end,
timeout=12.6,
}
local res=getMsg({ local res=getMsg({
pool='getCode', pool='getCode',
path='/techmino/api/v1/auth/verify/email', path='/techmino/api/v1/auth/verify/email',
@@ -63,26 +111,23 @@ function NET.getCode(email)
USER.email=email USER.email=email
SCN.fileDropped(2) SCN.fileDropped(2)
MES.new('info',text.checkEmail,5) MES.new('info',text.checkEmail,5)
else
MES.new('error',res.message,5)
end end
else
MES.new('warn',text.requestFailed,5)
end end
WAIT.interrupt() WAIT.interrupt()
end) end)
WAIT{
quit=function()
TASK.unlock('getCode')
HTTP.deletePool('getCode')
end,
timeout=12.6,
}
end end
function NET.codeLogin(code) function NET.codeLogin(code)
if not TASK.lock('codeLogin') then return end if not TASK.lock('codeLogin') then return end
TASK.new(function() TASK.new(function()
WAIT{
quit=function()
TASK.unlock('codeLogin')
HTTP.deletePool('codeLogin')
end,
timeout=6.26,
}
local res=getMsg({ local res=getMsg({
pool='codeLogin', pool='codeLogin',
path='/techmino/api/v1/auth/login/email', path='/techmino/api/v1/auth/login/email',
@@ -96,34 +141,31 @@ function NET.codeLogin(code)
if res.code==200 then if res.code==200 then
USER.rToken=res.data.refreshToken USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
NET.connectWS() NET.ws.connect()
SCN.pop()SCN.go('net_menu') SCN.pop()SCN.go('net_menu')
elseif res.code==201 then elseif res.code==201 then
USER.rToken=res.data.refreshToken USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
SCN.pop()SCN.push('net_menu') SCN.pop()SCN.push('net_menu')
SCN.fileDropped(3) SCN.fileDropped(3)
else
MES.new('error',res.message,5)
end end
else
MES.new('warn',text.requestFailed,5)
end end
WAIT.interrupt() WAIT.interrupt()
end) end)
WAIT{
quit=function()
TASK.unlock('codeLogin')
HTTP.deletePool('codeLogin')
end,
timeout=6.26,
}
end end
function NET.setPW(code,pw) function NET.setPW(code,pw)
if not TASK.lock('setPW') then return end if not TASK.lock('setPW') then return end
TASK.new(function() TASK.new(function()
pw=HASH.pbkdf2(HASH.sha3_256,pw,"salt",26000) WAIT{
quit=function()
TASK.unlock('setPW')
HTTP.deletePool('setPW')
end,
timeout=6.26,
}
pw=HASH.pbkdf2(HASH.sha3_256,pw,'salt',26000)
local res=getMsg({ local res=getMsg({
pool='setPW', pool='setPW',
@@ -140,22 +182,11 @@ function NET.setPW(code,pw)
if res.code==200 then if res.code==200 then
USER.password=pw USER.password=pw
SCN.back() SCN.back()
else
MES.new('error',res.message,5)
end end
else
MES.new('warn',text.requestFailed,5)
end end
WAIT.interrupt() WAIT.interrupt()
end) end)
WAIT{
quit=function()
TASK.unlock('setPW')
HTTP.deletePool('setPW')
end,
timeout=6.26,
}
end end
function NET.autoLogin() function NET.autoLogin()
if not USER.password then if not USER.password then
@@ -164,6 +195,14 @@ function NET.autoLogin()
end end
if not TASK.lock('autoLogin') then return end if not TASK.lock('autoLogin') then return end
TASK.new(function() TASK.new(function()
WAIT{
quit=function()
TASK.unlock('autoLogin')
HTTP.deletePool('autoLogin')
end,
timeout=12.6,
}
if USER.aToken then if USER.aToken then
local res=getMsg({ local res=getMsg({
pool='autoLogin', pool='autoLogin',
@@ -173,12 +212,10 @@ function NET.autoLogin()
if res then if res then
if res.code==200 then if res.code==200 then
NET.connectWS() NET.ws.connect()
SCN.go('net_menu') SCN.go('net_menu')
WAIT.interrupt() WAIT.interrupt()
return return
else
LOG("Access token expired")
end end
else else
WAIT.interrupt() WAIT.interrupt()
@@ -196,12 +233,10 @@ function NET.autoLogin()
if res.code==200 then if res.code==200 then
USER.rToken=res.data.refreshToken USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
NET.connectWS() NET.ws.connect()
SCN.go('net_menu') SCN.go('net_menu')
WAIT.interrupt() WAIT.interrupt()
return return
else
LOG("Refresh token expired")
end end
else else
WAIT.interrupt() WAIT.interrupt()
@@ -221,12 +256,10 @@ function NET.autoLogin()
if res.code==200 then if res.code==200 then
USER.rToken=res.data.refreshToken USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
NET.connectWS() NET.ws.connect()
SCN.go('net_menu') SCN.go('net_menu')
WAIT.interrupt() WAIT.interrupt()
return return
else
MES.new('warn',text.requestFailed)
end end
else else
WAIT.interrupt() WAIT.interrupt()
@@ -236,17 +269,19 @@ function NET.autoLogin()
SCN.go('login') SCN.go('login')
WAIT.interrupt() WAIT.interrupt()
end) end)
WAIT{
quit=function()
TASK.unlock('autoLogin')
HTTP.deletePool('autoLogin')
end,
timeout=12.6,
}
end end
function NET.pwLogin(email,pw) function NET.pwLogin(email,pw)
if not TASK.lock('pwLogin') then return end if not TASK.lock('pwLogin') then return end
TASK.new(function() TASK.new(function()
WAIT{
quit=function()
TASK.unlock('pwLogin')
HTTP.deletePool('pwLogin')
end,
timeout=12.6,
}
TEST.yieldT(.26)
pw=HASH.pbkdf2(HASH.sha3_256,pw,"salt",26000) pw=HASH.pbkdf2(HASH.sha3_256,pw,"salt",26000)
local res=getMsg({ local res=getMsg({
@@ -264,24 +299,13 @@ function NET.pwLogin(email,pw)
USER.password=pw USER.password=pw
USER.rToken=res.data.refreshToken USER.rToken=res.data.refreshToken
USER.aToken=res.data.accessToken USER.aToken=res.data.accessToken
NET.connectWS() NET.ws.connect()
SCN.go('net_menu') SCN.go('net_menu')
else
MES.new('error',res.message,5)
end end
else
MES.new('warn',text.requestFailed,5)
end end
WAIT.interrupt() WAIT.interrupt()
end) end)
WAIT{
quit=function()
TASK.unlock('pwLogin')
HTTP.deletePool('pwLogin')
end,
timeout=12.6,
}
end end
--------------------------<NEW WS API> --------------------------<NEW WS API>
@@ -295,14 +319,20 @@ end
-- Room -- Room
NET.room={} NET.room={}
function NET.room.chat(mes,rid) function NET.room.chat(msg,rid)
wsSend(1300,{ wsSend(1300,{
message=mes, message=msg,
roomId=rid,-- Admin roomId=rid,-- Admin
}) })
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('enterRoom',6) then return end if not TASK.lock('createRoom',6) then return end
WAIT{
quit=function()
TASK.unlock('createRoom')
end,
timeout=1e99,
}
wsSend(1301,{ wsSend(1301,{
capacity=capacity, capacity=capacity,
info={ info={
@@ -314,12 +344,6 @@ function NET.room.create(roomName,description,capacity,roomType,roomData,passwor
data=roomData, data=roomData,
password=password, password=password,
}) })
WAIT{
quit=function()
TASK.unlock('enterRoom')
end,
timeout=1e99,
}
end end
function NET.room.getData(rid) function NET.room.getData(rid)
wsSend(1302,{ wsSend(1302,{
@@ -391,8 +415,8 @@ NET.player={}
function NET.player.updateConf() function NET.player.updateConf()
wsSend(1200,dumpBasicConfig()) wsSend(1200,dumpBasicConfig())
end end
function NET.player.finish(mes)-- what mes? function NET.player.finish(msg)-- what msg?
wsSend(1201,mes) wsSend(1201,msg)
end end
function NET.player.joinGroup(gid) function NET.player.joinGroup(gid)
wsSend(1202,gid) wsSend(1202,gid)
@@ -417,67 +441,68 @@ function NET.player.setPlaying(playing)
end end
-- WS -- WS
function NET.connectWS() NET.ws={}
function NET.ws.connect()
if WS.status('game')=='dead' then if WS.status('game')=='dead' then
WS.connect('game','',{['x-access-token']=USER.aToken},6) WS.connect('game','',{['x-access-token']=USER.aToken},6)
TASK.new(NET.updateWS) TASK.new(NET.ws.update)
end end
end end
function NET.closeWS() function NET.ws.close()
WS.close('game') WS.close('game')
end end
function NET.updateWS() function NET.ws.update()
while WS.status('game')~='dead' do while WS.status('game')~='dead' do
coroutine.yield() coroutine.yield()
local message,op=WS.read('game') local msg,op=WS.read('game')
if message then if msg then
if op=='ping' then if op=='ping' then
elseif op=='pong' then elseif op=='pong' then
elseif op=='close' then elseif op=='close' then
local res=JSON.decode(message) local res=JSON.decode(msg)
MES.new('info',("$1 $2"):repD(text.wsClose,res and res.message or message)) MES.new('info',("$1 $2"):repD(text.wsClose,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 while SCN.stack[#SCN.stack-1]~='main' do SCN.pop() end
SCN.back() SCN.back()
return return
else else
local res=JSON.decode(message) local body=JSON.decode(msg)
if res then if body then
-- print(("RECV ACT: $1 ($2)"):repD(res.action,res.type)) -- print(("RECV ACT: $1 ($2)"):repD(res.action,res.type))
if res.type=='Failed' then if body.type=='Failed' then
MES.new('warn',text.requestFailed..": "..(res.reason or "/")) parseError(body.message~=nil and body.message or msg)
elseif res.action==1100 then-- TODO elseif body.action==1100 then-- TODO
elseif res.action==1101 then-- TODO elseif body.action==1101 then-- TODO
elseif res.action==1102 then-- TODO elseif body.action==1102 then-- TODO
elseif res.action==1201 then-- Finish elseif body.action==1201 then-- Finish
elseif res.action==1202 then-- Join group elseif body.action==1202 then-- Join group
elseif res.action==1203 then-- Set ready elseif body.action==1203 then-- Set ready
elseif res.action==1204 then-- Set host elseif body.action==1204 then-- Set host
elseif res.action==1205 then-- Set state elseif body.action==1205 then-- Set state
elseif res.action==1206 then-- Stream elseif body.action==1206 then-- Stream
elseif res.action==1207 then-- Set playing elseif body.action==1207 then-- Set playing
elseif res.action==1301 then-- Create room elseif body.action==1301 then-- Create room
TASK.unlock('createRoom')
-- NET.roomState=...
-- SCN.go('net_game')
WAIT.interrupt()
elseif body.action==1302 then-- Get room data
elseif body.action==1303 then-- Set room data
elseif body.action==1304 then-- Get room info
elseif body.action==1305 then-- Set room info
elseif body.action==1306 then-- Enter room
TASK.unlock('enterRoom') TASK.unlock('enterRoom')
-- NET.roomState=... -- NET.roomState=...
-- SCN.go('net_game') -- SCN.go('net_game')
WAIT.interrupt() WAIT.interrupt()
elseif res.action==1302 then-- Get room data elseif body.action==1307 then-- Kick room
elseif res.action==1303 then-- Set room data elseif body.action==1308 then-- Leave room
elseif res.action==1304 then-- Get room info elseif body.action==1309 then-- Fetch rooms
elseif res.action==1305 then-- Set room info
elseif res.action==1306 then-- Enter room
TASK.unlock('enterRoom')
-- NET.roomState=...
-- SCN.go('net_game')
WAIT.interrupt()
elseif res.action==1307 then-- Kick room
elseif res.action==1308 then-- Leave room
elseif res.action==1309 then-- Fetch rooms
TASK.unlock('fetchRoom') TASK.unlock('fetchRoom')
if res.data then SCN.scenes.net_rooms.widgetList.roomList:setList(res.data) end if body.data then SCN.scenes.net_rooms.widgetList.roomList:setList(body.data) end
elseif res.action==1310 then-- Set password elseif body.action==1310 then-- Set password
elseif res.action==1311 then-- Remove room elseif body.action==1311 then-- Remove room
end end
else else
WS.alert('user') WS.alert('user')

View File

@@ -9,7 +9,7 @@ function scene.sceneInit()
sysAndScn=SYSTEM.."-"..VERSION.string.." scene:"..Z.getErr('#').scene sysAndScn=SYSTEM.."-"..VERSION.string.." scene:"..Z.getErr('#').scene
errorText=LOADED and text.errorMsg or "An error has occurred while the game was loading.\nAn error log has been created so you can send it to the author." errorText=LOADED and text.errorMsg or "An error has occurred while the game was loading.\nAn error log has been created so you can send it to the author."
errorShot,errorInfo=Z.getErr('#').shot,Z.getErr('#').mes errorShot,errorInfo=Z.getErr('#').shot,Z.getErr('#').mes
NET.closeWS() NET.ws.close()
if SETTING then if SETTING then
SFX.fplay('error',SETTING.voc*.8 or 0) SFX.fplay('error',SETTING.voc*.8 or 0)
end end

View File

@@ -239,7 +239,7 @@ end
function scene.update(dt) function scene.update(dt)
if WS.status('game')~='running' then if WS.status('game')~='running' then
NET.closeWS() NET.ws.close()
SCN.back() SCN.back()
return return
end end

View File

@@ -4,7 +4,7 @@ function scene.sceneInit()
BG.set() BG.set()
end end
function scene.sceneBack() function scene.sceneBack()
NET.closeWS() NET.ws.close()
end end
function scene.draw() function scene.draw()
@@ -24,7 +24,7 @@ scene.widgetList={
USER.__data.password=false USER.__data.password=false
USER.__data.rToken=false USER.__data.rToken=false
USER.__data.aToken=false USER.__data.aToken=false
NET.closeWS() NET.ws.close()
SCN.back() SCN.back()
end end
end}, end},