From 7d90a4dcfc9d69a7b9a882e4c2feec0fd985eeb9 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 22 Feb 2021 01:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83ws=E5=BA=93=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E8=BF=9E=E6=8E=A5=E6=88=90=E5=8A=9F=E6=97=B6=E5=88=B7?= =?UTF-8?q?=E6=96=B0ping=E5=92=8Cpong=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/websocket.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index a0dd2623..5ba1039a 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -178,7 +178,7 @@ end function WS.close(name) local ws=wsList[name] - ws.sendCHN:push(8) + ws.sendCHN:push(8)--close ws.sendCHN:push("") ws.status="dead" end @@ -190,10 +190,12 @@ function WS.update() if ws.status=="connecting"then if ws.readCHN:pop()=="success"then ws.status="running" + ws.lastPingTime=time + ws.lastPongTime=time end elseif time-ws.lastPingTime>ws.pingInterval then ws.sendCHN:push(9) - ws.sendCHN:push("") + ws.sendCHN:push("")--ping ws.lastPingTime=time end if time-ws.lastPongTime>10+3*ws.pingInterval then