This commit is contained in:
laodaming 2023-09-22 11:47:32 +08:00
parent fc50bf587f
commit e1094b9be6
2 changed files with 4 additions and 20 deletions

View File

@ -67,9 +67,9 @@ var (
//websocket连接存储
mapConnPool = sync.Map{}
//每个websocket连接入口缓冲队列长度默认值
websocketInChanLen = 500
websocketInChanLen = 1000
//每个websocket连接出口缓冲队列长度默认值
websocketOutChanLen = 500
websocketOutChanLen = 1000
//是否开启debug
openDebug = true
//允许跨域的origin
@ -192,9 +192,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
userId: userInfo.UserId,
guestId: userInfo.GuestId,
extendRenderProperty: extendRenderProperty{
renderChan: make(chan websocket_data.RenderImageReqMsg, renderChanLen),
colorSelectedIndex: 0,
templateTag: "",
renderChan: make(chan websocket_data.RenderImageReqMsg, renderChanLen),
},
}
//保存连接

View File

@ -32,9 +32,7 @@ type renderProcessor struct {
// 云渲染属性
type extendRenderProperty struct {
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
colorSelectedIndex int //选择颜色索引
templateTag string //模板标签
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
}
// 处理分发到这里的数据
@ -50,8 +48,6 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
case <-w.closeChan: //已经关闭
return
case w.extendRenderProperty.renderChan <- renderImageData: //发入到缓冲队列
w.extendRenderProperty.colorSelectedIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex
w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag
return
}
}
@ -71,16 +67,6 @@ 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.colorSelectedIndex {
logx.Info("丢弃切换了颜色之前的渲染")
continue
}
limitChan <- struct{}{}
go func(d websocket_data.RenderImageReqMsg) {
defer func() {