修改刷新房间相关代码

This commit is contained in:
MrZ626
2021-03-30 14:55:46 +08:00
parent 20f031fcb4
commit 23c0c63c6a
7 changed files with 64 additions and 56 deletions

View File

@@ -2,7 +2,7 @@ local data=love.data
local NET={
login=false,
allow_online=false,
roomList=false,
roomList={},
accessToken=false,
}
@@ -26,6 +26,9 @@ end
local function _unlock(name)
locks[name]=false
end
function NET.getLock(name)
return locks[name]
end
--Parse json message
local function _parse(res)
@@ -119,15 +122,17 @@ function NET.signal_quit()
end
--Room
function NET.freshRoom()
WS.send("play",JSON.encode{
action=0,
data={
type=nil,
begin=0,
count=10,
}
})
function NET.fetchRoom()
if _lock("fetchRoom")then
WS.send("play",JSON.encode{
action=0,
data={
type=nil,
begin=0,
count=10,
}
})
end
end
function NET.createRoom()
if _lock("enterRoom")then
@@ -266,6 +271,7 @@ function NET.TICK_WS_play()
SCN.go("net_menu")
elseif res.action==0 then--Fetch rooms
NET.roomList=res.roomList
_unlock("fetchRoom")
elseif res.action==2 then--Join(create) room
-- loadGame("netBattle",true,true)
_unlock("enterRoom")