From ad7feed5bf992cfa9bb3bf8374160dc9f64d81ff Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 03:42:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=90=AF=E7=94=A8ws-play?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 1 - parts/gametoolfunc.lua | 13 +++++----- parts/scenes/net_rooms.lua | 52 ++++++++++++++++++++------------------ 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/main.lua b/main.lua index 1f74bb39..d0b3add4 100644 --- a/main.lua +++ b/main.lua @@ -27,7 +27,6 @@ LOGIN=false EDITING="" NET={ allow_online=false, - try_enter_netmenu=false, } ERRDATA={} diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 814ac235..b6985574 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -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 diff --git a/parts/scenes/net_rooms.lua b/parts/scenes/net_rooms.lua index 2d7e86a7..3226ff21 100644 --- a/parts/scenes/net_rooms.lua +++ b/parts/scenes/net_rooms.lua @@ -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")