diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 5aca8d95..e488c8d1 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -23,7 +23,7 @@ var ( //每个websocket渲染任务缓冲队列长度默认值 renderChanLen = 500 //每个websocket渲染并发数 - renderChanConcurrency = 15 + renderChanConcurrency = 3 ) // 渲染处理器 @@ -33,6 +33,8 @@ type renderProcessor struct { // 云渲染属性 type extendRenderProperty struct { renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列 + selectColorIndex int //颜色选中索引 + templateTag string //模板标签 } // 处理分发到这里的数据 @@ -48,6 +50,8 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) { case <-w.closeChan: //已经关闭 return case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列 + w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag + w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex return } } @@ -67,6 +71,14 @@ func (w *wsConnectItem) consumeRenderImageData() { case <-w.closeChan: //已关闭 return case data := <-w.extendRenderProperty.renderChan: //消费数据 + if data.RenderData.TemplateTag != w.extendRenderProperty.templateTag{ + logx.Info("由于模板切换了,丢弃该渲染消息") + continue + } + if data.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex{ + logx.Info("由于模板切换了颜色,丢弃该渲染消息") + continue + } limitChan <- struct{}{} go func(d websocket_data.RenderImageReqMsg) { defer func() { @@ -202,6 +214,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe logx.Error("failed to find render resource:", err) return } + logx.Info("无缓存的渲染图,需要unity") } else { //返回给客户端 w.sendRenderResultData(websocket_data.RenderImageRspMsg{