This commit is contained in:
laodaming 2023-08-31 10:35:13 +08:00
parent 0efa99665e
commit a94aab855a

View File

@ -194,15 +194,8 @@ func (w *wsConnectItem) renderImage(data []byte) {
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
return
}
//发送合图结果消息
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
RenderId: renderImageData.RenderId,
CombineImage: combineImage,
CombineProcessTime: websocket_data.CombineProcessTime{
CombineTakesTime: fmt.Sprintf("%dms", res.DiffTimeLogoCombine),
UploadCombineImageTakesTime: fmt.Sprintf("%dms", res.DiffTimeUploadFile),
},
}))
//发送合图完毕阶段消息
w.sendCombineImageStepResponseMessage(renderImageData.RenderId, combineImage, res.DiffTimeLogoCombine, res.DiffTimeUploadFile)
//如果指定指定只返回刀版图
if renderImageData.OnlyReturnCombineImage {
logx.Info("云渲染传入size id则不走unity云渲染,只返回刀版图render_id:", renderImageData.RenderId)
@ -322,7 +315,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
},
}
//发送运行阶段消息(组装数据)
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: info.RenderId}))
w.sendAssembleRenderDataStepResponseMessage(info.RenderId)
sendData := map[string]interface{}{
"id": taskId,
"order_id": 0,
@ -362,11 +355,33 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
},
})
//发送运行阶段消息
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: info.RenderId}))
w.sendRenderDataToUnityStepResponseMessage(info.RenderId)
logx.Info("发送到unity成功,刀版图:", combineImage /*, " 请求unity的数据:", string(postDataBytes)*/)
return nil
}
// 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, combineImage string, combineMsTime, uploadMsTime int64) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
RenderId: renderId,
CombineImage: combineImage,
CombineProcessTime: websocket_data.CombineProcessTime{
CombineTakesTime: fmt.Sprintf("%dms", combineMsTime),
UploadCombineImageTakesTime: fmt.Sprintf("%dms", uploadMsTime),
},
}))
}
// 发送组装unity渲染数据完毕阶段通知消息
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(renderId string) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RenderId: renderId}))
}
// 发送组装unity渲染数据完毕阶段通知消息
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RenderId: renderId}))
}
// 增加渲染任务
func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) {
if data.taskId == "" {