尝试启用ws-play

This commit is contained in:
MrZ626
2021-03-28 03:42:00 +08:00
parent 411d4dc1b3
commit ad7feed5bf
3 changed files with 34 additions and 32 deletions

View File

@@ -27,7 +27,6 @@ LOGIN=false
EDITING="" EDITING=""
NET={ NET={
allow_online=false, allow_online=false,
try_enter_netmenu=false,
} }
ERRDATA={} ERRDATA={}

View File

@@ -1168,7 +1168,6 @@ do
if res.id then if res.id then
USER.id=res.id USER.id=res.id
USER.authToken=res.authToken USER.authToken=res.authToken
NET.try_enter_netmenu=true
WS.send("user",JSON.encode{action=0}) WS.send("user",JSON.encode{action=0})
end end
FILE.save(USER,"conf/user","q") FILE.save(USER,"conf/user","q")
@@ -1184,10 +1183,10 @@ do
elseif res.action==0 then elseif res.action==0 then
USER.accessToken=res.accessToken USER.accessToken=res.accessToken
LOG.print(text.accessSuccessed) LOG.print(text.accessSuccessed)
if NET.try_enter_netmenu then WS.connect("play","/play",JSON.encode{
NET.try_enter_netmenu=false id=USER.id,
SCN.go("net_menu") accessToken=USER.accessToken,
end })
elseif res.action==1 then elseif res.action==1 then
USER.name=res.username USER.name=res.username
USER.motto=res.motto USER.motto=res.motto
@@ -1239,7 +1238,9 @@ do
return return
else else
local res=JSON.decode(message) local res=JSON.decode(message)
--TODO if res.message=="Connected"then
SCN.go("net_menu")
end
end end
end end
end end

View File

@@ -6,26 +6,27 @@ local scrollPos,selected
local lastfreshTime local lastfreshTime
local lastCreateRoomTime=0 local lastCreateRoomTime=0
local function enterRoom(roomID)
--[[TODO
WS.connect("play","/play",JSON.encode{
email=USER.email,
token=USER.accessToken,
id=roomID,
conf=dumpBasicConfig(),
-- password=password,
})
]]
end
local function fresh() local function fresh()
lastfreshTime=TIME() lastfreshTime=TIME()
rooms=nil rooms=nil
--[[TODO WS.send("play","/play",JSON.encode{
WS.connect("play","/play",JSON.encode{ action=0,
email=USER.email, data={
accessToken=USER.accessToken, type=nil,
}) begin=0,
]] count=10,
}
})
end
local function enterRoom(roomID,password)
WS.send("play","/play",JSON.encode{
action=2,
data={
rid=roomID,
conf=dumpBasicConfig(),
password=password,
}
})
end end
local scene={} local scene={}
@@ -47,14 +48,15 @@ function scene.keyDown(k)
end end
elseif k=="n"then elseif k=="n"then
if TIME()-lastCreateRoomTime>26 then if TIME()-lastCreateRoomTime>26 then
--[[TODO WS.send("play",JSON.encode{
WS.send("room",JSON.encode{ action=1,
email=USER.email, data={
accessToken=USER.accessToken, type=nil,
room_name=(USER.name or"???").."'s room", name=(USER.name or"???").."'s room",
room_password=nil, password=nil,
}) conf=dumpBasicConfig(),
]] }
})
lastCreateRoomTime=TIME() lastCreateRoomTime=TIME()
else else
LOG.print(text.createRoomTooFast,"warn") LOG.print(text.createRoomTooFast,"warn")