diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 66b2e626..c7f05b3a 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -234,14 +234,12 @@ func (w *wsConnectItem) sendLoop() { } // 把要传递给客户端的数据放入outchan -func (w *wsConnectItem) sendToOutChan(data [][]byte) { - for _, v := range data { - select { - case <-w.closeChan: - return - case w.outChan <- v: - logx.Info("notify send render result to out chan") - } +func (w *wsConnectItem) sendToOutChan(data []byte) { + select { + case <-w.closeChan: + return + case w.outChan <- data: + logx.Info("notify send render result to out chan") } } diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 064b459d..97570811 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -63,7 +63,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi if !ok { return false } - dataList := make([][]byte, 0, len(req.NotifyList)) //遍历数据 for _, notifyItem := range req.NotifyList { renderKey := ws.getRenderImageMapKey(notifyItem.ProductId, notifyItem.SizeId, notifyItem.TemplateId) @@ -78,19 +77,18 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi ProductId: notifyItem.ProductId, SizeId: notifyItem.SizeId, TemplateId: notifyItem.TemplateId, - Source: "我是渲染资源", + Source: notifyItem.Source, }, } b, _ := json.Marshal(rspData) - dataList = append(dataList, b) //删除对应的需要渲染的图片map ws.renderImageTaskCtlChan <- renderImageControlChanItem{ - Option: 0, + Option: 0, //0删除 1添加 Key: renderKey, } + //发送数据到out chan + ws.sendToOutChan(b) } - //发送数据 - ws.sendToOutChan(dataList) return true }) return resp.SetStatus(basic.CodeOK) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index c8b7f816..3fca11ca 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -2,14 +2,12 @@ package logic import ( "encoding/json" - "fmt" "fusenapi/server/websocket/internal/types" "github.com/zeromicro/go-zero/core/logx" ) // 渲染请求数据处理发送云渲染服务处理 func (w *wsConnectItem) SendToCloudRender(data []byte) { - fmt.Println(string(data)) var renderImageData []types.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { logx.Error("invalid format of websocket render image message", err) @@ -25,7 +23,7 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) { //加入渲染任务 key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId) w.renderImageTaskCtlChan <- renderImageControlChanItem{ - Option: 1, + Option: 1, //0删除 1添加 Key: key, } // TODO 数据发送给云渲染服务器