diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 6cfc70c2..6a68e932 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -73,6 +73,34 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image") } uploadUnityRenderImageTakesTime := time.Now().UTC().UnixMilli() - unityRenderEndTime + //传了唯一标识,则精确查找 + if req.Wid != "" { + if value, ok := mapConnPool.Load(req.Wid); ok { + //断言连接 + ws, ok := value.(wsConnectItem) + if !ok { + logx.Error("渲染回调断言websocket连接失败") + return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "渲染回调断言websocket连接失败") + } + //记录收到unity渲染结果时间以及上传渲染图耗时时间 + ws.modifyRenderTaskProperty(renderImageControlChanItem{ + option: 2, + taskId: req.TaskId, + taskProperty: renderTask{ + unityRenderEndTime: unityRenderEndTime, + uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime, + }, + }) + //发送处理并删除任务 + ws.deleteRenderTask(renderImageControlChanItem{ + option: 0, //0删除 1添加 2修改耗时属性 + taskId: req.TaskId, + renderNotifyImageUrl: uploadRes.ResourceUrl, + }) + } + logx.Info("渲染回调成功,渲染结果图片为:", uploadRes.ResourceUrl) + return resp.SetStatusWithMessage(basic.CodeOK, "success") + } //遍历websocket链接把数据传进去 mapConnPool.Range(func(key, value any) bool { //断言连接 diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index f56eb527..a26c11a6 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -6,7 +6,8 @@ import ( ) type RenderNotifyReq struct { - TaskId string `json:"task_id"` //任务id + Wid string `json:"wid,optional"` //websocket连接唯一标识 + TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` Image string `json:"image"` diff --git a/server_api/websocket.api b/server_api/websocket.api index 34e02ad4..f707417b 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -22,7 +22,8 @@ service websocket { //渲染完了通知接口 type RenderNotifyReq { - TaskId string `json:"task_id"` //任务id + Wid string `json:"wid,optional"` //websocket连接唯一标识 + TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` Image string `json:"image"`