优化ws代码结构
This commit is contained in:
parent
34c8014c95
commit
d9daae7829
|
@ -41,8 +41,6 @@ type renderImageControlChanItem struct {
|
||||||
// 渲染任务属性
|
// 渲染任务属性
|
||||||
type renderTask struct {
|
type renderTask struct {
|
||||||
renderId string //渲染id(新增任务传)
|
renderId string //渲染id(新增任务传)
|
||||||
combineTakesTime int64 //合刀版图耗时
|
|
||||||
uploadCombineImageTakesTime int64 //上传刀版图耗时
|
|
||||||
unityRenderBeginTime int64 //发送给unity时间
|
unityRenderBeginTime int64 //发送给unity时间
|
||||||
unityRenderEndTime int64 //unity回调结果时间
|
unityRenderEndTime int64 //unity回调结果时间
|
||||||
uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间
|
uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间
|
||||||
|
@ -190,9 +188,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||||
RenderId: renderImageData.RenderId,
|
RenderId: renderImageData.RenderId,
|
||||||
Image: *resource.ResourceUrl,
|
Image: *resource.ResourceUrl,
|
||||||
RenderProcessTime: websocket_data.RenderProcessTime{
|
RenderProcessTime: websocket_data.RenderProcessTime{
|
||||||
CombineTakesTime: "cache",
|
|
||||||
UnityRenderTakesTime: "cache",
|
UnityRenderTakesTime: "cache",
|
||||||
UploadCombineImageTakesTime: "cache",
|
|
||||||
UploadUnityRenderImageTakesTime: "cache",
|
UploadUnityRenderImageTakesTime: "cache",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -201,8 +197,6 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||||
//###########################################
|
//###########################################
|
||||||
//把需要渲染的图片任务加进去
|
//把需要渲染的图片任务加进去
|
||||||
w.createRenderTask(taskId, renderImageData.RenderId)
|
w.createRenderTask(taskId, renderImageData.RenderId)
|
||||||
//记录刀版图合成消耗时间跟上传刀版图时间以及刀版图
|
|
||||||
w.modifyRenderTaskProperty(taskId, renderTask{combineTakesTime: res.DiffTimeLogoCombine, uploadCombineImageTakesTime: res.DiffTimeUploadFile})
|
|
||||||
//组装数据
|
//组装数据
|
||||||
if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil {
|
if err = w.assembleRenderDataToUnity(taskId, combineImage, renderImageData, productTemplate, model3dInfo, element, productSize); err != nil {
|
||||||
logx.Error("组装数据失败:", err)
|
logx.Error("组装数据失败:", err)
|
||||||
|
@ -395,13 +389,21 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送合图完毕阶段通知消息
|
// 发送合图完毕阶段通知消息
|
||||||
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, combineImage string, combineMsTime, uploadMsTime int64) {
|
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, combineImage string, combineTime, uploadTime int64) {
|
||||||
|
combineTakesTime := "cache"
|
||||||
|
uploadCombineImageTakesTime := "cache"
|
||||||
|
if combineTime > 0 {
|
||||||
|
combineTakesTime = fmt.Sprintf("%dms", combineTime)
|
||||||
|
}
|
||||||
|
if uploadTime > 0 {
|
||||||
|
uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
|
||||||
|
}
|
||||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
|
||||||
RenderId: renderId,
|
RenderId: renderId,
|
||||||
CombineImage: combineImage,
|
CombineImage: combineImage,
|
||||||
CombineProcessTime: websocket_data.CombineProcessTime{
|
CombineProcessTime: websocket_data.CombineProcessTime{
|
||||||
CombineTakesTime: fmt.Sprintf("%dms", combineMsTime),
|
CombineTakesTime: combineTakesTime,
|
||||||
UploadCombineImageTakesTime: fmt.Sprintf("%dms", uploadMsTime),
|
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -534,18 +536,8 @@ func (w *wsConnectItem) operationRenderTask() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//存在任务,则发送渲染结果给前端
|
//存在任务,则发送渲染结果给前端
|
||||||
CombineTakesTime := "cache"
|
|
||||||
UnityRenderTakesTime := "cache"
|
UnityRenderTakesTime := "cache"
|
||||||
uploadCombineImageTakesTime := "cache"
|
|
||||||
uploadUnityRenderImageTakesTime := "cache"
|
uploadUnityRenderImageTakesTime := "cache"
|
||||||
//合图时间
|
|
||||||
if taskData.combineTakesTime > 0 {
|
|
||||||
CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime)
|
|
||||||
}
|
|
||||||
//上传刀版图时间
|
|
||||||
if taskData.uploadCombineImageTakesTime > 0 {
|
|
||||||
uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime)
|
|
||||||
}
|
|
||||||
//unity渲染时间
|
//unity渲染时间
|
||||||
if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 {
|
if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 {
|
||||||
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime)
|
UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime)
|
||||||
|
@ -559,9 +551,7 @@ func (w *wsConnectItem) operationRenderTask() {
|
||||||
RenderId: taskData.renderId,
|
RenderId: taskData.renderId,
|
||||||
Image: data.renderNotifyImageUrl,
|
Image: data.renderNotifyImageUrl,
|
||||||
RenderProcessTime: websocket_data.RenderProcessTime{
|
RenderProcessTime: websocket_data.RenderProcessTime{
|
||||||
CombineTakesTime: CombineTakesTime,
|
|
||||||
UnityRenderTakesTime: UnityRenderTakesTime,
|
UnityRenderTakesTime: UnityRenderTakesTime,
|
||||||
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
|
|
||||||
UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
|
UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -576,14 +566,6 @@ func (w *wsConnectItem) operationRenderTask() {
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//合图耗时
|
|
||||||
if data.taskProperty.combineTakesTime != 0 {
|
|
||||||
taskData.combineTakesTime = data.taskProperty.combineTakesTime
|
|
||||||
}
|
|
||||||
//上传合图耗时
|
|
||||||
if data.taskProperty.uploadCombineImageTakesTime != 0 {
|
|
||||||
taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime
|
|
||||||
}
|
|
||||||
//上传渲染结果图耗时
|
//上传渲染结果图耗时
|
||||||
if data.taskProperty.uploadUnityRenderImageTakesTime != 0 {
|
if data.taskProperty.uploadUnityRenderImageTakesTime != 0 {
|
||||||
taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime
|
taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime
|
||||||
|
|
|
@ -35,9 +35,7 @@ type RenderImageRspMsg struct {
|
||||||
RenderProcessTime RenderProcessTime `json:"render_process_time"` //流程耗时
|
RenderProcessTime RenderProcessTime `json:"render_process_time"` //流程耗时
|
||||||
}
|
}
|
||||||
type RenderProcessTime struct {
|
type RenderProcessTime struct {
|
||||||
CombineTakesTime string `json:"combine_takes_time"` //合图需要时间
|
|
||||||
UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时
|
UnityRenderTakesTime string `json:"unity_render_takes_time"` //unity渲染用时
|
||||||
UploadCombineImageTakesTime string `json:"upload_combine_image_takes_time"` //上传刀版图耗时
|
|
||||||
UploadUnityRenderImageTakesTime string `json:"upload_unity_render_image_takes_time"` //上传unity渲染结果图时间
|
UploadUnityRenderImageTakesTime string `json:"upload_unity_render_image_takes_time"` //上传unity渲染结果图时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user