This commit is contained in:
laodaming 2023-08-17 16:16:27 +08:00
parent 6dba8507a7
commit cda5c69f4f

View File

@ -40,14 +40,16 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend
// }
func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
logx.Info("收到渲染回调数据:", *req)
if req.TaskId == "" {
logx.Error("渲染回调参数错误invalid param task_id")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
}
if req.Image == "" {
logx.Error("渲染回调参数错误invalid param image")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image")
}
if req.UserId == 0 && req.GuestId == 0 {
logx.Error("渲染回调参数错误invalid user_id or guest_id")
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id")
}
// 上传文件
@ -68,7 +70,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
FileByte: nil,
})
if err != nil {
logx.Error(err)
logx.Error("渲染回调上传文件失败:", err)
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
}
//遍历websocket链接把数据传进去
@ -76,6 +78,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
//断言连接
ws, ok := value.(wsConnectItem)
if !ok {
logx.Error("渲染回调断言websocket连接失败")
return true
}
//关闭标识
@ -102,10 +105,10 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
case ws.renderProperty.renderImageTaskCtlChan <- deleteTask: //删除对应的需要渲染的图片map
//发送数据到out chan
ws.sendToOutChan(b)
return true
case <-time.After(time.Second * 3): //超时丢弃
return true
}
return true
})
logx.Info("渲染回调成功######################")
return resp.SetStatusWithMessage(basic.CodeOK, "success")