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) } }