From 70544827cd6ab020c253291d9aa4a3e9adb3149e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 23 Aug 2023 15:54:02 +0800 Subject: [PATCH] fix --- server/websocket/internal/logic/datatransferlogic.go | 2 +- .../websocket/internal/logic/ws_render_image_logic.go | 11 +++++------ .../websocket/internal}/websocket_data/render_data.go | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) rename {utils => server/websocket/internal}/websocket_data/render_data.go (97%) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 64f5634e..1fee63bf 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -5,8 +5,8 @@ import ( "bytes" "encoding/json" "fusenapi/constants" + "fusenapi/server/websocket/internal/websocket_data" "fusenapi/utils/auth" - "fusenapi/utils/websocket_data" "net/http" "sync" "time" diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index a8294400..1a4587e5 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -7,11 +7,10 @@ import ( "errors" "fmt" "fusenapi/constants" + websocket_data2 "fusenapi/server/websocket/internal/websocket_data" "fusenapi/service/repositories" "fusenapi/utils/curl" "fusenapi/utils/hash" - "fusenapi/utils/websocket_data" - "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" "strconv" @@ -76,7 +75,7 @@ func (w *wsConnectItem) renderImage() { // 消费渲染缓冲数据 func (w *wsConnectItem) consumeRenderCache(data []byte) { logx.Info("消费渲染数据:", string(data)) - var renderImageData websocket_data.RenderImageReqMsg + var renderImageData websocket_data2.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) logx.Error("invalid format of websocket render image message", err) @@ -142,7 +141,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { } } else { //返回给客户端 - b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + b := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data2.RenderImageRspMsg{ RenderId: renderImageData.RenderId, Image: *resource.ResourceUrl, CombineTakesTime: "耗时0秒(缓存)", @@ -167,7 +166,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { } // 组装数据发送给unity -func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) error { +func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data2.RenderImageReqMsg) error { //获取产品第一个尺寸 productFirstSize, err := w.logic.svcCtx.AllModels.FsProductSize.GetProductFirstSize(w.logic.ctx, info.RenderData.ProductId) if err != nil { @@ -429,7 +428,7 @@ func (w *wsConnectItem) operationRenderTask() { UnityRenderTakesTime = fmt.Sprintf("耗时%d秒", taskData.UnityRenderEndTime-taskData.UnityRenderBeginTime) } //发送到出口 - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data2.RenderImageRspMsg{ RenderId: taskData.RenderId, Image: data.RenderNotifyImageUrl, CombineTakesTime: CombineTakesTime, diff --git a/utils/websocket_data/render_data.go b/server/websocket/internal/websocket_data/render_data.go similarity index 97% rename from utils/websocket_data/render_data.go rename to server/websocket/internal/websocket_data/render_data.go index b95b4169..cbc5e1eb 100644 --- a/utils/websocket_data/render_data.go +++ b/server/websocket/internal/websocket_data/render_data.go @@ -2,7 +2,7 @@ package websocket_data import "fusenapi/constants" -// websocket数据交互 +// websocket数据交互基本数据类型 type DataTransferData struct { T constants.Websocket `json:"t"` //消息类型 D interface{} `json:"d"` //传递的消息