From ad20c62c737daf7e716e73a49a4daad81806e25f Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 19:28:11 +0800 Subject: [PATCH 01/16] test1 --- Zframework/init.lua | 1 + parts/scenes/main.lua | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 924688c0..92152c92 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -511,6 +511,7 @@ function love.run() if SCN.swapping then SCN.swapUpdate()end--Scene swapping animation WIDGET.update()--Widgets animation LOG.update() + WS.update() --DRAW if not MINI()then diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 830e65dd..9f90dd9c 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -44,6 +44,9 @@ function scene.sceneInit() PLY.newDemoPlayer(1) PLAYERS[1]:setPosition(520,140,.8) love.keyboard.setKeyRepeat(false) + + --Connect to server + TASK.new(TICK_WS_app) end function scene.sceneBack() love.keyboard.setKeyRepeat(true) @@ -81,7 +84,6 @@ function scene.keyDown(key) TEXT.show(text.notFinished,640,450,60,"flicker") SFX.play("finesseError") elseif LOGIN then - --[[TODO if USER.accessToken then WS.send("app",JSON.encode{ opration="access", @@ -92,10 +94,9 @@ function scene.keyDown(key) WS.send("app",JSON.encode{ opration="access", email=USER.email, - authToken=USER.authToken, + authToken=USER.authToken, }) end - ]] else SCN.go("login") end From c0155ad275c418a59675ec284d11423483c00d40 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 21:00:29 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E9=98=B2=E7=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index 337ce287..79e0d378 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -72,7 +72,10 @@ do--Connect --First line of HTTP local l=SOCK:receive("*l") - local code=l:find(" "); code=l:sub(code+1,code+3) + local code + if l then + code=l:find(" "); code=l:sub(code+1,code+3) + end if code=="101"then readCHN:push("success") From a3ff9dacc8de0687c8bce1e41fe68cab347db90b Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 21:11:41 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index 79e0d378..4273fdf5 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -77,16 +77,16 @@ do--Connect code=l:find(" "); code=l:sub(code+1,code+3) end + local ctLen + repeat + l=SOCK:receive("*l") + if not ctLen and l:find"Length"then + ctLen=tonumber(l:match"%d+") + end + until l=="" if code=="101"then readCHN:push("success") else - local ctLen - repeat - l=SOCK:receive("*l") - if not ctLen and l:find"Length"then - ctLen=tonumber(l:match"%d+") - end - until l=="" local reason=JSON.decode(SOCK:receive(ctLen)) readCHN:push(code..":"..(reason and reason.message or"Server Error")) end From 29af52c72e7eafcc9b7e50693e9c2e9fc6b59c0a Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 22:04:56 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E4=BC=9A=E7=88=86=E7=82=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index 4273fdf5..ec4aec37 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -72,18 +72,16 @@ do--Connect --First line of HTTP local l=SOCK:receive("*l") - local code + local code,ctLen if l then code=l:find(" "); code=l:sub(code+1,code+3) + repeat + l=SOCK:receive("*l") + if not ctLen and l:find"Length"then + ctLen=tonumber(l:match"%d+") + end + until l=="" end - - local ctLen - repeat - l=SOCK:receive("*l") - if not ctLen and l:find"Length"then - ctLen=tonumber(l:match"%d+") - end - until l=="" if code=="101"then readCHN:push("success") else From 01f779ef37253665512c575f81f75ab37622d268 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 22:06:24 +0800 Subject: [PATCH 05/16] =?UTF-8?q?ws=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index ec4aec37..594adeec 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -223,7 +223,7 @@ function WS.update() ws.lastPongTime=time else ws.status="dead" - LOG.print(text.wsFailed,"warn") + LOG.print(text.wsFailed.." "..mes,"warn") end end elseif time-ws.lastPingTime>ws.pingInterval then From 783defbbed3be3a4b5d5fb89c0f8fd6af542b5a9 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 22:15:14 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=94=B9=E4=B8=BA=E5=8A=A0=E8=BD=BD=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/load.lua | 4 ++++ parts/scenes/main.lua | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index c6633031..876c65e7 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -176,6 +176,10 @@ local loadingThread=coroutine.create(function() end STAT.run=STAT.run+1 LOADED=true + + --Connect to server + TASK.new(TICK_WS_app) + --[[TODO WS.send("user",JSON.encode{ id=USER.id, diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 9f90dd9c..0c9e1f6b 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -44,9 +44,6 @@ function scene.sceneInit() PLY.newDemoPlayer(1) PLAYERS[1]:setPosition(520,140,.8) love.keyboard.setKeyRepeat(false) - - --Connect to server - TASK.new(TICK_WS_app) end function scene.sceneBack() love.keyboard.setKeyRepeat(true) From 86a696ad1504c42c38a690e2698f54507528c787 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 22:16:38 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8FLATES?= =?UTF-8?q?T=5FVERSION=E6=94=B9=E4=B8=BAALLOW=5FONLINE=EF=BC=8Cws-app?= =?UTF-8?q?=E8=83=BD=E6=8E=A5=E6=94=B6=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.lua | 2 +- parts/gametoolfunc.lua | 14 +++++++------- parts/scenes/main.lua | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/main.lua b/main.lua index 47ba5950..d0ac8f48 100644 --- a/main.lua +++ b/main.lua @@ -26,7 +26,7 @@ DAILYLAUNCH=false LOGIN=false EDITING="" WSCONN=false -LATEST_VERSION=false +ALLOW_ONLINE=false ERRDATA={} --System setting diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index f7698d02..08699a46 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1223,20 +1223,22 @@ do if message then if op=="ping"then WS.send("app",message,"pong") - --TODO: ping animation - --TODO: what to do with res? elseif op=="close"then LOG.print(text.wsClose..message,"warn") return else message=JSON.decode(message) + if VERSION_CODE>=message.lowest then + ALLOW_ONLINE=true + end + if VERSION_CODE Date: Sat, 27 Mar 2021 22:37:36 +0800 Subject: [PATCH 08/16] =?UTF-8?q?ws-app=E8=83=BD=E6=8E=A5=E5=85=AC?= =?UTF-8?q?=E5=91=8A=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 08699a46..ab2a4808 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1234,6 +1234,7 @@ do if VERSION_CODE Date: Sat, 27 Mar 2021 22:43:45 +0800 Subject: [PATCH 09/16] =?UTF-8?q?ws=E7=8A=B6=E6=80=81=E5=8F=AA=E5=9C=A8deb?= =?UTF-8?q?ug=E6=A8=A1=E5=BC=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 47 +++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/Zframework/init.lua b/Zframework/init.lua index 92152c92..bf2d66fc 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -557,27 +557,6 @@ function love.run() _.draw(_.time) end - --Draw network working status - gc_push("transform") - gc.translate(SCR.w,0) - gc.scale(SCR.k) - for i=1,5 do - local status=WS.status(WSnames[i]) - gc_setColor(WScolor[i]) - gc_rectangle("fill",0,20*i,-20,-20) - if status=="dead"then - gc_setColor(.8,.8,.8) - gc_draw(TEXTURE.ws_dead,-20,20*i-20) - elseif status=="connecting"then - gc_setColor(.8,.8,.8,.5+.3*sin(t*6.26)) - gc_draw(TEXTURE.ws_connecting,-20,20*i-20) - elseif status=="running"then - gc_setColor(.8,.8,.8) - gc_draw(TEXTURE.ws_running,-20,20*i-20) - end - end - gc_pop() - --Draw FPS gc_setColor(1,1,1) setFont(15) @@ -586,17 +565,43 @@ function love.run() --Debug info. if devMode then + --Left-down infos gc_setColor(devColor[devMode]) gc_print("MEM "..gcinfo(),SCR.safeX+5,_-40) gc_print("Lines "..FREEROW.getCount(),SCR.safeX+5,_-60) gc_print("Cursor "..int(mx+.5).." "..int(my+.5),SCR.safeX+5,_-80) gc_print("Voices "..VOC.getQueueCount(),SCR.safeX+5,_-100) gc_print("Tasks "..TASK.getCount(),SCR.safeX+5,_-120) + + --Update & draw frame time ins(frameTimeList,1,dt)rem(frameTimeList,126) gc_setColor(1,1,1,.3) for i=1,#frameTimeList do gc_rectangle("fill",150+2*i,_-20,2,-frameTimeList[i]*4000) end + + --Websocket status + gc_push("transform") + gc.translate(SCR.w,0) + gc.scale(SCR.k) + for i=1,5 do + local status=WS.status(WSnames[i]) + gc_setColor(WScolor[i]) + gc_rectangle("fill",0,20*i,-20,-20) + if status=="dead"then + gc_setColor(.8,.8,.8) + gc_draw(TEXTURE.ws_dead,-20,20*i-20) + elseif status=="connecting"then + gc_setColor(.8,.8,.8,.5+.3*sin(t*6.26)) + gc_draw(TEXTURE.ws_connecting,-20,20*i-20) + elseif status=="running"then + gc_setColor(.8,.8,.8) + gc_draw(TEXTURE.ws_running,-20,20*i-20) + end + end + gc_pop() + + --Slow devmode if devMode==3 then WAIT(.1) elseif devMode==4 then WAIT(.5) end From 8891367791bf7d3e0dca83aa65dad22702bb1341 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 23:50:37 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90app?= =?UTF-8?q?=E5=92=8Cuser=E7=9A=84ws=EF=BC=8C=E5=8A=A0=E8=BD=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E6=97=B6=E8=BF=9E=E6=8E=A5=E6=9B=B4=E5=A4=9Aws?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 233 ++++++++++++++++++++--------------------- parts/scenes/load.lua | 10 +- 2 files changed, 121 insertions(+), 122 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index ab2a4808..72f04463 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1066,19 +1066,6 @@ end --Network funcs do --[[ - launch: - local res=JSON.decode(res.body) - if res.message=="OK"then - LOG.print(res.notice,360,COLOR.sky) - if VERSION_CODE>=res.version_code then - LATEST_VERSION=true - else - LOG.print(string.gsub(text.oldVersion,"$1",res.version_name),"warn") - end - else - LOG.print(text.httpCode..res.code..": "..res.message,"warn") - end - register: if response.message=="OK"then LOGIN=true @@ -1092,95 +1079,6 @@ do LOG.print(text.httpCode..response.code..": "..res.message,"warn") end - autoLogin: - if res.message=="OK"then - LOGIN=true - LOG.print(text.loginSuccessed) - httpRequest( - TICK_httpREQ_getUserInfo, - PATH.http..PATH.user, - "GET", - {["Content-Type"]="application/json"}, - JSON.encode{ - email=USER.email, - authToken=USER.authToken, - } - ) - else - LOGIN=false - LOG.print(text.loginFailed..": "..text.httpCode..res.code.."-"..res.message,"warn") - end - return - - newLogin: - if res.message=="OK"then - LOGIN=true - USER.email=res.email - USER.authToken=res.authToken - USER.id=res.id - FILE.save(USER,"conf/user","q") - LOG.print(text.loginSuccessed) - - --TODO:getUserInfo - JSON.encode{ - email=USER.email, - authToken=USER.authToken, - } - - --TODO:getAccessToken - JSON.encode{ - email=USER.email, - authToken=USER.authToken, - } - else - LOG.print(text.httpCode..res.code..": "..res.message,"warn") - end - - manualAutoLogin: - if res.message=="OK"then - LOG.print(text.accessSuccessed) - SCN.go("net_menu") - elseif res.code==403 or res.code==401 then - httpRequest( - TICK_httpREQ_getAccessToken, - PATH.http..PATH.access, - "POST", - {["Content-Type"]="application/json"}, - JSON.encode{ - email=USER.email, - authToken=USER.authToken, - } - ) - else - local err=JSON.decode(res.body) - if err then - LOG.print(text.httpCode..res.code..": "..err.message,"warn") - end - end - - getAccessToken: - if res.message=="OK"then - LOG.print(text.accessSuccessed) - USER.accessToken=res.accessToken - FILE.save(USER,"conf/user") - SCN.swapTo("net_menu") - else - LOGIN=false - USER.accessToken=false - USER.authToken=false - LOG.print(text.loginFailed..": "..text.httpCode..response.code.."-"..res.message,"warn") - end - - getUserInfo: - if res.message=="OK"then - USER.name=res.username - USER.motto=res.motto - USER.avatar=res.avatar - FILE.save(USER,"conf/user") - else - LOG.print("Get user info failed: "..text.httpCode..response.code.."-"..res.message,"warn") - end - goChatRoom: if res.message=="OK"then SCN.go("net_chat") @@ -1204,7 +1102,6 @@ do LOG.print(text.httpCode..res.code..": "..res.message,"warn") end - enterRoom: if res.message=="OK"then loadGame("netBattle",true,true) @@ -1215,6 +1112,8 @@ do ]] function TICK_WS_app() + local initial=true + local retryTime=5 while true do YIELD() local status=WS.status("app") @@ -1224,25 +1123,79 @@ do if op=="ping"then WS.send("app",message,"pong") elseif op=="close"then - LOG.print(text.wsClose..message,"warn") + message=JSON.decode(message) + if message then + LOG.print(text.wsClose..message.message,"warn") + end return else - message=JSON.decode(message) - if VERSION_CODE>=message.lowest then + local res=JSON.decode(message) + if VERSION_CODE>=res.lowest then ALLOW_ONLINE=true end - if VERSION_CODE Date: Sat, 27 Mar 2021 23:51:01 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/login.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index 4b9b1447..c36fe663 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -6,12 +6,11 @@ local function login() elseif #password==0 then LOG.print(text.noPassword)return end - --[[TODO - WS.send("user",JSON.encode{ - email=email, - password=password, - }) - ]] + USER.email=email + WS.send("user",JSON.encode{ + email=email, + password=password, + }) end local scene={} From 4207d1b03f5d04a1f119e3149fe08b3e91e0a577 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 00:52:39 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5ws-app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 6 +----- parts/scenes/load.lua | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 72f04463..4eb611a3 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1112,7 +1112,6 @@ do ]] function TICK_WS_app() - local initial=true local retryTime=5 while true do YIELD() @@ -1142,10 +1141,7 @@ do elseif status=="dead"then retryTime=retryTime-1 if retryTime==0 then return end - if initial then - for _=1,120 do YIELD()end - initial=false - end + for _=1,120 do YIELD()end WS.connect("app","/app") end end diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index fb0c1041..94e5634e 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -180,7 +180,7 @@ local loadingThread=coroutine.create(function() --Connect to server TASK.new(TICK_WS_app) TASK.new(TICK_WS_user) - TASK.new(TICK_WS_chat) + WS.connect("app","/app") if USER.authToken then WS.connect("user","/user",JSON.encode{ id=USER.id, From 2f8f27289410518f4ecd46c787101884351cce6e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 00:52:59 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/login.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parts/scenes/login.lua b/parts/scenes/login.lua index c36fe663..4885f58b 100644 --- a/parts/scenes/login.lua +++ b/parts/scenes/login.lua @@ -7,7 +7,7 @@ local function login() LOG.print(text.noPassword)return end USER.email=email - WS.send("user",JSON.encode{ + WS.connect("user","/user",JSON.encode{ email=email, password=password, }) @@ -17,8 +17,8 @@ local scene={} scene.widgetList={ WIDGET.newText{name="title", x=80, y=50,font=70,align="L"}, - -- WIDGET.newButton{name="register", x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("register","swipeR")end}, - WIDGET.newInputBox{name="email", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z@._-]"}, + -- WIDGET.newButton{name="register",x=1140, y=100,w=170,h=80,color="green",code=function()SCN.swapTo("register","swipeR")end}, + WIDGET.newInputBox{name="email", x=380, y=200,w=500,h=60,regex="[0-9A-Za-z@._-]"}, WIDGET.newInputBox{name="password", x=380, y=300,w=626,h=60,secret=true,regex="[ -~]"}, WIDGET.newKey{name="login", x=1140, y=540,w=170,h=80,font=40,code=login}, WIDGET.newButton{name="back", x=1140, y=640,w=170,h=80,font=40,code=backScene}, From a195b89a71c780f4b6e8a2cab0d734475fb02d1c Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 01:14:41 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E9=94=99?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 4eb611a3..4135920a 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1149,12 +1149,12 @@ do function TICK_WS_user() while true do YIELD() - local status=WS.status("chat") + local status=WS.status("user") if status=="running"then - local message,op=WS.read("chat") + local message,op=WS.read("user") if message then if op=="ping"then - WS.send("chat",message,"pong") + WS.send("user",message,"pong") elseif op=="close"then message=JSON.decode(message) if message then From 62f3a834dccd05d494b9e4ebf7b51b8d4d11d1d4 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 01:58:41 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E4=B8=BB=E8=8F=9C=E5=8D=95=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8C=89=E9=92=AE=E9=80=BB=E8=BE=91=E6=94=B9=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/main.lua | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index d9ab7b57..296b34bb 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -81,19 +81,10 @@ function scene.keyDown(key) TEXT.show(text.notFinished,640,450,60,"flicker") SFX.play("finesseError") elseif LOGIN then - if USER.accessToken then - WS.send("app",JSON.encode{ - opration="access", - email=USER.email, - accessToken=USER.accessToken, - }) - else - WS.send("app",JSON.encode{ - opration="access", - email=USER.email, - authToken=USER.authToken, - }) - end + SCN.go("net_menu") + WS.send("user",JSON.encode{ + action=0, + }) else SCN.go("login") end From af710acf9e8219a421ac67520296d889179940d8 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 02:00:16 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=81=9A=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 4135920a..faa0ce0e 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -1163,15 +1163,17 @@ do return else local res=JSON.decode(message) - if res.messages=="Connected"then + if res.message=="Connected"then LOGIN=true - USER.authToken=res.authToken - USER.id=res.id + if res.id then + USER.id=res.id + USER.authToken=res.authToken + SCN.go("net_menu") + end FILE.save(USER,"conf/user","q") LOG.print(text.loginSuccessed) - WS.send("user",JSON.encode{ - action=0, - }) + + --Get self infos WS.send("user",JSON.encode{ action=1, data={ @@ -1180,7 +1182,7 @@ do }) elseif res.action==0 then USER.accessToken=res.accessToken - FILE.save(USER,"conf/user") + LOG.print(text.accessSuccessed) elseif res.action==1 then USER.name=res.username USER.motto=res.motto