fusenapi/server/websocket/internal/logic/ws_ok_response.go

70 lines
2.3 KiB
Go
Raw Normal View History

2023-10-18 09:07:19 +00:00
package logic
import (
"fmt"
"fusenapi/constants"
"fusenapi/utils/auth"
"fusenapi/utils/websocket_data"
)
// *******************************合图相关begin******************************
// 发送合图完毕阶段通知消息
2023-10-27 09:46:24 +00:00
func (w *wsConnectItem) sendCombineImageStepResponseMessage(requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
2023-10-18 09:07:19 +00:00
if w.debug == nil {
return
}
2023-10-20 06:36:16 +00:00
combineTakesTime := ""
uploadCombineImageTakesTime := ""
//开了缓存
if w.debug.IsCache != 0 {
combineTakesTime = "cache"
uploadCombineImageTakesTime = "cache"
}
2023-10-20 06:28:34 +00:00
if debugData != nil && debugData.DiffTimeLogoCombine > 0 {
2023-10-18 09:07:19 +00:00
combineTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeLogoCombine)
}
2023-10-20 06:28:34 +00:00
if debugData != nil && debugData.DiffTimeUploadFile > 0 {
2023-10-18 09:07:19 +00:00
uploadCombineImageTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeUploadFile)
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
RequestId: requestId,
CombineImage: combineImage,
SizeId: sizeId,
ModelId: modelId,
TemplateId: templateId,
CombineProcessTime: websocket_data.CombineProcessTime{
CombineTakesTime: combineTakesTime,
UploadCombineImageTakesTime: uploadCombineImageTakesTime,
},
}))
}
// 发送组装unity需要的数据完毕消息
2023-10-27 09:46:24 +00:00
func (w *wsConnectItem) sendAssembleRenderDataStepResponseMessage(requestId string) {
2023-10-18 09:07:19 +00:00
if w.debug == nil {
return
}
2023-10-27 09:46:24 +00:00
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ASSEMBLE_RENDER_DATA, websocket_data.ToUnityRspMsg{RequestId: requestId}))
2023-10-18 09:07:19 +00:00
}
// 发送组装数据到unity完毕阶段通知消息
2023-10-27 09:46:24 +00:00
func (w *wsConnectItem) sendRenderDataToUnityStepResponseMessage(requestId string) {
2023-11-01 03:22:29 +00:00
//统计unity处理数
increaseUnityRequestCount(w.userId, w.guestId)
2023-10-18 09:07:19 +00:00
if w.debug == nil {
return
}
2023-10-27 09:46:24 +00:00
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_SEND_DATA_TO_UNITY, websocket_data.AssembleRenderDataRspMsg{RequestId: requestId}))
2023-10-18 09:07:19 +00:00
}
// 发送渲染最终结果数据到前端
func (w *wsConnectItem) sendRenderResultData(data websocket_data.RenderImageRspMsg) {
2023-10-18 09:22:07 +00:00
//没开启debug
if w.debug == nil {
data.RenderProcessTime = websocket_data.RenderProcessTime{}
}
2023-10-18 09:07:19 +00:00
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, data))
}
// *******************************合图相关end******************************