From 66c16329acab25f9a7b28840fce6a4bf85bd9b22 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 27 Mar 2021 19:19:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E5=B0=8F=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, 6 insertions(+), 8 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index f44c62ad..337ce287 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -84,10 +84,8 @@ do--Connect ctLen=tonumber(l:match"%d+") end until l=="" - l=SOCK:receive(ctLen) - local reason=JSON.decode(l) - if reason then reason=reason.message end - readCHN:push(code.."-"..(reason or l)) + local reason=JSON.decode(SOCK:receive(ctLen)) + readCHN:push(code..":"..(reason and reason.message or"Server Error")) end else readCHN:push(err) @@ -97,7 +95,7 @@ end -while true do +while true do--Running triggerCHN:demand() while sendCHN:getCount()>=2 do local op=sendCHN:pop() @@ -137,7 +135,7 @@ while true do reason=JSON.decode(res)if reason then reason=reason.message end readCHN:push(code.."-"..(reason or res)) else - readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2).."-"..res:sub(3,-3))) + readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2),res:sub(3,-3))) end else readCHN:push(res) @@ -196,8 +194,8 @@ end function WS.read(name) local ws=wsList[name] if ws.readCHN:getCount()>=2 then - local op=ws.readCHN.pop() - local message=ws.readCHN.pop() + local op=ws.readCHN:pop() + local message=ws.readCHN:pop() if op==8 then ws.status="dead"end ws.lastPongTime=timer() return message,op