尝试启用ws-play
This commit is contained in:
1
main.lua
1
main.lua
@@ -27,7 +27,6 @@ LOGIN=false
|
||||
EDITING=""
|
||||
NET={
|
||||
allow_online=false,
|
||||
try_enter_netmenu=false,
|
||||
}
|
||||
ERRDATA={}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user