From ef2346efa02ca83ff9a5f5990bef2b34156fcd05 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 12 May 2021 22:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E8=A7=A3=E6=9E=90=E6=9D=A5=E8=87=AA=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E7=9A=84=E5=88=87=E6=96=ADws=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 3 +-- parts/net.lua | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index baf8fe5a..5ee99f2a 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -188,8 +188,7 @@ while true do--Running readCHN:push(op) SOCK:close() if type(res)=='string'then - res=JSON.decode(res) - readCHN:push(res and res.reason or"WS Error") + readCHN:push(res)--Warning: with 2 bytes close code else readCHN:push("WS Error") end diff --git a/parts/net.lua b/parts/net.lua index 7554b55f..cf76cda2 100644 --- a/parts/net.lua +++ b/parts/net.lua @@ -80,11 +80,11 @@ end --WS close message local function wsCloseMessage(message) - local mes=JSON.decode(message) + local mes=JSON.decode(message:sub(3)) if mes then - LOG.print(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""),'warn') + LOG.print(("%s [%s] %s"):format(text.wsClose,mes.type or"unknown type",mes.reason or""),'error') else - LOG.print(text.wsClose.."",'warn') + LOG.print(text.wsClose,'error') end end