From f9ed93641cd940c84acea7c95a8e1e436033686b Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 6 Jun 2021 17:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ws=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?debug=E5=BC=80=E5=85=B3=E5=8F=98=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index de0ce4fc..56492f44 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -1,11 +1,12 @@ --- local host="127.0.0.1" --- local host="192.168.114.102" -local host="krakens.tpddns.cn" --- local host="game.techmino.org" +local host= + -- "127.0.0.1" + -- "192.168.114.102" + "krakens.tpddns.cn" + -- "game.techmino.org" local port="10026" local path="/tech/socket/v1" -local debug=""--S:send, R:receive, M=mark +local debugMode=""--S:send, R:receive, M=mark local wsThread=[[ -- lua + LÖVE threading websocket client @@ -87,7 +88,7 @@ local _send do local mask_str=char(unpack(mask_key)) function _send(op,message) - ]]..(debug:find'S'and""or"--")..[[print((">> %s[%d]:%s"):format(threadName,#message,message)) + ]]..(debugMode:find'S'and""or"--")..[[print((">> %s[%d]:%s"):format(threadName,#message,message)) --Message type SOCK:send(char(bor(0x80,op))) @@ -154,7 +155,7 @@ while true do--Running if s then res=s elseif p then--UNF head - ]]..(debug:find'R'and""or"--")..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50))) + ]]..(debugMode:find'R'and""or"--")..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50))) UFF=true sBuffer=sBuffer..p length=length-#p @@ -166,11 +167,11 @@ while true do--Running else local s,e,p=SOCK:receive(length) if s then - ]]..(debug:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50))) + ]]..(debugMode:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50))) sBuffer=sBuffer..s length=length-#s elseif p then - ]]..(debug:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50))) + ]]..(debugMode:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50))) sBuffer=sBuffer..p length=length-#p end @@ -181,7 +182,7 @@ while true do--Running break end end - ]]..(debug:find'R'and""or"--")..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150))) + ]]..(debugMode:find'R'and""or"--")..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150))) --React if op==8 then--8=close @@ -195,21 +196,21 @@ while true do--Running elseif op==0 then--0=continue lBuffer=lBuffer..res if fin then - ]]..(debug:find'M'and""or"--")..[[print("FIN=1 (c") + ]]..(debugMode:find'M'and""or"--")..[[print("FIN=1 (c") readCHN:push(lBuffer) lBuffer="" else - ]]..(debug:find'M'and""or"--")..[[print("FIN=0 (c") + ]]..(debugMode:find'M'and""or"--")..[[print("FIN=0 (c") end else readCHN:push(op) if fin then - ]]..(debug:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=1") + ]]..(debugMode:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=1") readCHN:push(res) else - ]]..(debug:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=0") + ]]..(debugMode:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=0") sBuffer=res - ]]..(debug:find'M'and""or"--")..[[print("START pack: "..res) + ]]..(debugMode:find'M'and""or"--")..[[print("START pack: "..res) end end end