diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 9ef4303b..68f4006d 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -1,16 +1,20 @@ package logic import ( + "bytes" "encoding/json" "errors" "fmt" "fusenapi/constants" "fusenapi/service/repositories" + "fusenapi/utils/curl" "fusenapi/utils/hash" "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" + "os" "strconv" + "time" ) // 云渲染属性 @@ -234,20 +238,24 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re "is_thousand_face": 0, "folder": "", //todo 千人千面需要使用 } - /*b, _ := json.Marshal(sendData) - if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil { - logx.Error("发送渲染组装数据到rabbitmq失败:", err) - return nil - } - logx.Info("发送渲染组装数据到unity成功")*/ // todo 请求unity接口 /api/render/queue/push - logx.Info(sendData["id"]) - //模拟发送回去(unity部署后要去掉) - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ - RenderId: info.RenderId, - Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png", - })) - return + url := "http://api.fusen.3718.cn:4050/api/render/queue/push" + header := make(map[string]string) + header["content-type"] = "application/json" + t := time.Now().UTC() + postData := map[string]interface{}{ + "group": "unity3d", + "source": "home page", + "priority": 1, + "create_at": t, + "render_data": sendData, + } + p, _ := json.Marshal(postData) + _, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*20) + if err != nil { + logx.Error("failed to send data to unity") + return + } } // 操作连接中渲染任务的增加/删除