This commit is contained in:
laodaming 2023-10-10 17:49:47 +08:00
parent 5e9c1df5da
commit 9e71d9a60f
2 changed files with 22 additions and 4 deletions

View File

@ -48,6 +48,7 @@ func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (res
logx.Error("测试异常:", err)
}
}()
//lenAiHost := len(l.svcCtx.Config.)
begin := time.Now().UTC().UnixMilli()
errChan := make(chan string)
w := sync.WaitGroup{}

View File

@ -34,10 +34,11 @@ type renderProcessor struct {
// 云渲染属性
type extendRenderProperty struct {
renderChan chan websocket_data.RenderImageReqMsg //渲染消息入口的缓冲队列
renderCtx context.Context //渲染控制上下文(用于切换模板标签/颜色取消之前发送的不相同的任务)
renderCtx context.Context //渲染控制上下文(用于切换模板标签/颜色/logo取消之前发送的不相同的任务)
renderCtxCancelFunc context.CancelFunc //渲染控制上下文取消方法
selectColorIndex int //选择的颜色索引
templateTag string //模板标签
selectColorIndex int //选择的颜色索引(用于标记连接当前连接选择的颜色)
templateTag string //模板标签 (用于标记连接当前连接选择的模板标签)
Logo string //logo地址 用于标记连接当前连接选择的logo
}
// 处理分发到这里的数据
@ -49,10 +50,22 @@ func (r *renderProcessor) allocationMessage(w *wsConnectItem, data []byte) {
logx.Error("invalid format of websocket render image message", err)
return
}
if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag || renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex {
//颜色/模板标签/logo变更
ifCancelOldCtx := false
if renderImageData.RenderData.TemplateTag != w.extendRenderProperty.templateTag {
ifCancelOldCtx = true
}
if renderImageData.RenderData.TemplateTagColor.SelectedColorIndex != w.extendRenderProperty.selectColorIndex {
ifCancelOldCtx = true
}
if renderImageData.RenderData.Logo != w.extendRenderProperty.Logo {
ifCancelOldCtx = true
}
if ifCancelOldCtx {
//赋值
w.extendRenderProperty.templateTag = renderImageData.RenderData.TemplateTag
w.extendRenderProperty.selectColorIndex = renderImageData.RenderData.TemplateTagColor.SelectedColorIndex
w.extendRenderProperty.Logo = renderImageData.RenderData.Logo
//让之前的失效
w.extendRenderProperty.renderCtxCancelFunc()
//重新赋值
@ -94,6 +107,10 @@ func (w *wsConnectItem) consumeRenderImageData() {
//logx.Info("颜色不一致,丢弃消息")
continue
}
//logo不一样
if data.RenderData.Logo != w.extendRenderProperty.Logo {
continue
}
limitChan <- struct{}{}
go func(d websocket_data.RenderImageReqMsg) {
defer func() {