尝试启用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=""
NET={
allow_online=false,
try_enter_netmenu=false,
}
ERRDATA={}

View File

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

View File

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