This commit is contained in:
laodaming 2023-10-16 15:26:45 +08:00
parent 7f88233f28
commit a1e6be40db
2 changed files with 43 additions and 42 deletions

View File

@ -437,6 +437,34 @@ func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage st
return nil return nil
} }
// 组装渲染任务id
func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
//生成任务id(需要把user_id,guest_id设为0)
incomeHashParam := renderImageData.RenderData
incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
incomeHashParam.GuestId = 0 //设为0(渲染跟用户id无关)
incomeHashBytes, _ := json.Marshal(incomeHashParam)
modelHashStr := ""
templateHashStr := ""
if model3dInfo.ModelInfo != nil {
modelHashStr = *model3dInfo.ModelInfo
}
if productTemplate.TemplateInfo != nil {
templateHashStr = *productTemplate.TemplateInfo
}
elementHashBytes, _ := json.Marshal(element)
hashMap := map[string]interface{}{
"income_param": incomeHashBytes,
"model_info": modelHashStr,
"template_info": templateHashStr,
"material_image": *productTemplate.MaterialImg,
"render_element": elementHashBytes,
"combine_image": combineImage,
}
return hash.JsonHashKey(hashMap)
}
// ****************************下面的发送消息的*********************************
// 发送合图完毕阶段通知消息 // 发送合图完毕阶段通知消息
func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) { func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
if w.openDebug { if w.openDebug {
@ -481,30 +509,3 @@ func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(renderId string
func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) { func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) {
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data)) w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data))
} }
// 组装渲染任务id
func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
//生成任务id(需要把user_id,guest_id设为0)
incomeHashParam := renderImageData.RenderData
incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
incomeHashParam.GuestId = 0 //设为0(渲染跟用户id无关)
incomeHashBytes, _ := json.Marshal(incomeHashParam)
modelHashStr := ""
templateHashStr := ""
if model3dInfo.ModelInfo != nil {
modelHashStr = *model3dInfo.ModelInfo
}
if productTemplate.TemplateInfo != nil {
templateHashStr = *productTemplate.TemplateInfo
}
elementHashBytes, _ := json.Marshal(element)
hashMap := map[string]interface{}{
"income_param": incomeHashBytes,
"model_info": modelHashStr,
"template_info": templateHashStr,
"material_image": *productTemplate.MaterialImg,
"render_element": elementHashBytes,
"combine_image": combineImage,
}
return hash.JsonHashKey(hashMap)
}

View File

@ -46,21 +46,6 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) {
userConnPoolCtlChan <- data userConnPoolCtlChan <- data
} }
// 根据用户索引发现链接并发送(广播)消息到出口队列
func sendToOutChanByUserIndex(userId, guestId int64, message []byte) {
data := userConnPoolCtlChanItem{
userId: userId,
guestId: guestId,
uniqueId: "",
message: message,
option: 2,
}
select {
case userConnPoolCtlChan <- data:
return
}
}
// 消费用户索引创建/删除/发送消息中的任务数据 // 消费用户索引创建/删除/发送消息中的任务数据
func ConsumeUserConnPoolCtlChanData(ctx context.Context) { func ConsumeUserConnPoolCtlChanData(ctx context.Context) {
defer func() { defer func() {
@ -130,3 +115,18 @@ func getmapUserConnPoolUniqueId(userId, guestId int64) (uniqueId string) {
} }
return fmt.Sprintf("%d_%d", userId, guestId) return fmt.Sprintf("%d_%d", userId, guestId)
} }
// 根据用户索引发现链接并发送(广播)消息到出口队列
func sendToOutChanByUserIndex(userId, guestId int64, message []byte) {
data := userConnPoolCtlChanItem{
userId: userId,
guestId: guestId,
uniqueId: "",
message: message,
option: 2,
}
select {
case userConnPoolCtlChan <- data:
return
}
}