This commit is contained in:
laodaming 2023-08-16 12:33:01 +08:00
parent a022e5a8d9
commit 37b5cc0f30

View File

@ -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,21 +238,25 @@ 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",
}))
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
}
}
// 操作连接中渲染任务的增加/删除
func (w *wsConnectItem) operationRenderTask() {