From 0eaa357de519d9c1e0908d46da1246525372e2ca Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 12 Sep 2023 11:05:52 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/ws_render_image.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index c5f89e0e..726521de 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -75,12 +75,17 @@ func (w *wsConnectItem) consumeRenderImageData() { logx.Error("func renderImage err:", err) } }() - tick := time.Tick(w.extendRenderProperty.renderConsumeTickTime) + var duration time.Duration = 1 + if w.extendRenderProperty.renderConsumeTickTime > 0 { + duration = w.extendRenderProperty.renderConsumeTickTime + } + ticker := time.NewTicker(duration) + defer ticker.Stop() for { select { case <-w.closeChan: //已关闭 return - case <-tick: //消费数据 + case <-ticker.C: //消费数据 w.renderImage(<-w.extendRenderProperty.renderChan) } }