This commit is contained in:
laodaming 2023-10-18 11:03:07 +08:00
parent 6a982689ef
commit 571e9e6fac
3 changed files with 31 additions and 20 deletions

View File

@ -95,7 +95,7 @@ type wsConnectItem struct {
inChan chan []byte //接受消息缓冲队列(基本属性)
outChan chan []byte //要发送回客户端的消息缓冲队列(基本属性)
mutex sync.Mutex //互斥锁(基本属性)
openDebug bool //是否开启debug
debug *auth.Debug //是否开启debug
userId int64 //用户id(基本属性)
guestId int64 //游客id(基本属性)
extendRenderProperty extendRenderProperty //扩展云渲染属性(扩展属性)
@ -222,7 +222,13 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
renderCtx: renderCtx,
renderCtxCancelFunc: renderCtxCancelFunc,
},
openDebug: true, //默认都开debug
debug: userInfo.Debug,
}
//先设置下debug(后面要删掉)
ws.debug = &auth.Debug{
Exp: &userInfo.Exp,
IsCache: 1,
IsAllTemplateTag: 0,
}
//保存连接
mapConnPool.Store(uniqueId, ws)

View File

@ -4,7 +4,7 @@ import "fusenapi/constants"
// 入口数据格式错误
func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
if !w.openDebug {
if w.debug == nil {
return
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, data))
@ -12,7 +12,7 @@ func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
// 渲染错误通知
func (w *wsConnectItem) renderErrResponse(renderId, requestId, templateTag, taskId, description string, productId, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
if !w.openDebug {
if w.debug == nil {
return
}
data := make(map[string]interface{})

View File

@ -210,7 +210,6 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
logx.Error("failed to get element ,", err)
return
}
//获取刀版图
combineReq := repositories.LogoCombineReq{
UserId: renderImageData.RenderData.UserId,
@ -229,6 +228,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
Index: renderImageData.RenderData.TemplateTagColor.SelectedColorIndex,
},
Resolution: renderImageData.RenderData.Resolution,
Debug: w.debug,
}
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
if err != nil {
@ -256,19 +256,24 @@ 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{
RenderId: renderImageData.RenderId,
RequestId: renderImageData.RequestId,
Image: *resource.ResourceUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
UnityRenderTakesTime: "cache",
UploadUnityRenderImageTakesTime: "cache",
},
})
return
} else { //有缓存
//如果没有debug或者debug模式下开启了缓存则返回缓存
if w.debug == nil || w.debug.IsCache == 1 {
//返回给客户端
w.sendRenderResultData(websocket_data.RenderImageRspMsg{
RenderId: renderImageData.RenderId,
RequestId: renderImageData.RequestId,
Image: *resource.ResourceUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
UnityRenderTakesTime: "cache",
UploadUnityRenderImageTakesTime: "cache",
},
})
return
}
//否则继续去unity
}
//组装数据
if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil {
@ -463,7 +468,7 @@ func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData web
// ****************************下面的发送消息的*********************************
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
if !w.openDebug {
if w.debug == nil {
return
}
combineTakesTime := "cache"
@ -490,7 +495,7 @@ func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId,
// 发送组装unity需要的数据完毕消息
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string, requestId string) {
if !w.openDebug {
if w.debug == nil {
return
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId, RequestId: requestId}))
@ -498,7 +503,7 @@ func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId strin
// 发送组装数据到unity完毕阶段通知消息
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string, requestId string) {
if !w.openDebug {
if w.debug == nil {
return
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId, RequestId: requestId}))