From b23f005348008e3f39876b72bd70ed726dc6d29e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 5 Dec 2020 22:20:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=AE=A4=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=BF=83=E8=B7=B3=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/chat.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parts/scenes/chat.lua b/parts/scenes/chat.lua index 2c8e6f6f..e47c26aa 100644 --- a/parts/scenes/chat.lua +++ b/parts/scenes/chat.lua @@ -8,6 +8,7 @@ local texts={} local remain--People in chat room local scroll--Bottom message no. local newMessasge=false--If there is a new message +local heartBeatTimer local function sendMessage() local W=WIDGET.active.text @@ -27,6 +28,7 @@ end local scene={} function scene.sceneInit() + heartBeatTimer=0 remain=nil scroll=#texts @@ -102,6 +104,13 @@ function scene.socketRead(mes) end end +function scene.update(dt) + heartBeatTimer=heartBeatTimer+dt + if heartBeatTimer>42 then + heartBeatTimer=0 + wsWrite("/ping") + end +end function scene.draw() setFont(25) gc.setColor(1,1,1)