This commit is contained in:
laodaming 2023-09-13 10:29:59 +08:00
parent 921098650e
commit 06b1ad1678
2 changed files with 15 additions and 4 deletions

View File

@ -51,13 +51,14 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
unityRenderEndTime := time.Now().UTC().UnixMilli()
//解析出真的taskId跟wid
splitSlice := strings.Split(req.TaskId, " ")
if len(splitSlice) != 2 {
if len(splitSlice) != 3 {
logx.Error("渲染回调参数错误task_id拆分得不到合理结果")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
}
//重新赋值(很重要)
req.TaskId = splitSlice[0]
wid := splitSlice[1]
renderId := splitSlice[2]
//存base64打印测试
/* f, _ := os.Create("b.txt")
defer f.Close()
@ -94,7 +95,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
//记录收到unity渲染结果时间以及上传渲染图耗时时间
ws.modifyRenderTaskProperty(req.TaskId, renderTask{unityRenderEndTime: unityRenderEndTime, uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime})
//发送处理并删除任务
ws.deleteRenderTask(req.TaskId, uploadRes.ResourceUrl)
ws.deleteRenderTask(req.TaskId, renderId, uploadRes.ResourceUrl)
}
logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl)
return resp.SetStatusWithMessage(basic.CodeOK, "success")

View File

@ -401,7 +401,7 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
//发送运行阶段消息(组装数据)
w.sendAssembleRenderDataStepResponseMessage(info.RenderId)
sendData := map[string]interface{}{
"id": taskId + " " + w.uniqueId, //空格分开
"id": taskId + " " + w.uniqueId + " " + info.RenderId, //空格分开
"order_id": 0,
"user_id": info.RenderData.UserId,
"guest_id": info.RenderData.GuestId,
@ -502,7 +502,7 @@ func (w *wsConnectItem) createRenderTask(taskId, renderId string) {
}
// 渲染回调处理并删除渲染任务
func (w *wsConnectItem) deleteRenderTask(taskId, renderNotifyImageUrl string) {
func (w *wsConnectItem) deleteRenderTask(taskId, renderId, renderNotifyImageUrl string) {
if taskId == "" {
logx.Error("task_id不能为空")
return
@ -510,6 +510,7 @@ func (w *wsConnectItem) deleteRenderTask(taskId, renderNotifyImageUrl string) {
data := renderImageControlChanItem{
option: 0,
taskId: taskId,
renderId: renderId,
renderNotifyImageUrl: renderNotifyImageUrl,
}
select {
@ -587,6 +588,15 @@ func (w *wsConnectItem) operationRenderTask() {
case 0: //渲染结果回调,删除任务
taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]
if !ok {
//发送到出口
w.sendRenderResultData(websocket_data.RenderImageRspMsg{
RenderId: data.renderId, //没有找到任务渲染id则用传进来的
Image: data.renderNotifyImageUrl,
RenderProcessTime: websocket_data.RenderProcessTime{
UnityRenderTakesTime: "unknown",
UploadUnityRenderImageTakesTime: "unknown",
},
})
continue
}
//删除任务