From eee6160565da9fbb2652ce91610bf5592560332b Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 14 Jun 2021 22:24:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dws=E8=BF=9E=E6=8E=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E4=B8=8D=E8=83=BD=E6=AD=A3=E7=A1=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 17 ++++++++++------- parts/language/lang_en.lua | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index ee8cb76a..a4398843 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -63,12 +63,16 @@ do--Connect --Result if ctLen then if code=="101"then - readCHN:push("success") + readCHN:push('success') else res,err=SOCK:receive(ctLen) - if not res then readCHN:push(err)return end - res=JSON.decode(res) - readCHN:push((code or"XXX")..":"..(res and res.reason or"Server Error")) + if not res then + readCHN:push(err) + else + res=JSON.decode(res) + readCHN:push((code or"XXX")..":"..(res and res.reason or"Server Error")) + end + return end end SOCK:settimeout(0) @@ -316,8 +320,7 @@ end function WS.read(name) local ws=wsList[name] if ws.real and ws.readCHN:getCount()>=2 then - local op=ws.readCHN:pop() - local message=ws.readCHN:pop() + local op,message=ws.readCHN:pop(),ws.readCHN:pop() if op==8 then ws.status='dead'end--8=close ws.lastPongTime=timer() ws.pongTimer=1 @@ -342,7 +345,7 @@ function WS.update(dt) if ws.status=='connecting'then local mes=ws.readCHN:pop() if mes then - if mes=="success"then + if mes=='success'then ws.status='running' ws.lastPingTime=time ws.lastPongTime=time diff --git a/parts/language/lang_en.lua b/parts/language/lang_en.lua index a51862cc..bea3f9d3 100644 --- a/parts/language/lang_en.lua +++ b/parts/language/lang_en.lua @@ -91,7 +91,7 @@ return{ accessFailed="Access Denied.", wsConnecting="Websocket: Connecting", - wsFailed="WebSocket: Connection Failed.", + wsFailed="WebSocket: Connection Failed", wsClose="WebSocket Closed: ", netTimeout="Network connection timeout",