From b740072209a149ea3e51cf08f789fcb8c02b25da Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Mar 2021 03:35:55 +0800 Subject: [PATCH] =?UTF-8?q?pong=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 5 +++++ Zframework/websocket.lua | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/Zframework/init.lua b/Zframework/init.lua index bf2d66fc..e89ff481 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -598,6 +598,11 @@ function love.run() gc_setColor(.8,.8,.8) gc_draw(TEXTURE.ws_running,-20,20*i-20) end + local lastPongTime=WS.lastPongTime(WSnames[i]) + if lastPongTime<1 then + gc_setColor(1,1,1,1-lastPongTime) + gc_rectangle("fill",0,20*i,-20,-20) + end end gc_pop() diff --git a/Zframework/websocket.lua b/Zframework/websocket.lua index 907c800b..eb1a91bd 100644 --- a/Zframework/websocket.lua +++ b/Zframework/websocket.lua @@ -174,6 +174,10 @@ function WS.status(name) return wsList[name]and wsList[name].status or"dead" end +function WS.lastPongTime(name) + return wsList[name]and timer()-wsList[name].lastPongTime or 999 +end + function WS.setPingInterval(name,time) local ws=wsList[name] ws.pingInterval=math.max(time or 1,2.6)