From ea963f4076e4a3b592b35a7d078b4d4c5f8af33c Mon Sep 17 00:00:00 2001 From: lijun Date: Thu, 23 Jan 2025 23:06:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E5=B8=A7by?= =?UTF-8?q?tes,=E5=9E=83=E5=9C=BE=E5=9B=9E=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index 868555f..ea048a2 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -195,11 +195,13 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, deviceId int) { count := 0 //定时器,发送计数器 tCount := 0 + var buf []byte //计算帧率 for { //从service获取当前帧 - buf, c := service.GetDeviceCurrentFrameV4(deviceId, count) + newBuf, c := service.GetDeviceCurrentFrameV4(deviceId, count) if c != count { + buf = newBuf count = c err2 := ws.WriteMessage(websocket.BinaryMessage, buf) if err2 != nil { @@ -221,7 +223,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, deviceId int) { } } } - buf = nil time.Sleep(100 * time.Millisecond) tCount++ }