Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
eb3828a86a
|
@ -45,7 +45,7 @@ var (
|
|||
},
|
||||
}
|
||||
//升级websocket
|
||||
upgrade = websocket.Upgrader{
|
||||
upgrader = websocket.Upgrader{
|
||||
//最大可读取大小 10M
|
||||
ReadBufferSize: 1024 * 10,
|
||||
//握手超时时间15s
|
||||
|
@ -86,9 +86,9 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
|
|||
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||
r.Header.Set("Authorization", "Bearer "+token)
|
||||
//设置Sec-Websocket-Protocol
|
||||
upgrade.Subprotocols = []string{token}
|
||||
upgrader.Subprotocols = []string{token}
|
||||
//升级websocket
|
||||
conn, err := upgrade.Upgrade(w, r, nil)
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
logx.Error("http upgrade websocket err:", err)
|
||||
return
|
||||
|
@ -133,14 +133,14 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
|
|||
logic: l,
|
||||
uniqueId: uniqueId,
|
||||
closeChan: make(chan struct{}, 1),
|
||||
inChan: make(chan []byte, 100),
|
||||
outChan: make(chan []byte, 100),
|
||||
inChan: make(chan []byte, 500),
|
||||
outChan: make(chan []byte, 500),
|
||||
userId: userInfo.UserId,
|
||||
guestId: userInfo.GuestId,
|
||||
renderProperty: renderProperty{
|
||||
renderImageTask: make(map[string]*renderTask),
|
||||
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100),
|
||||
renderChan: make(chan []byte, 100),
|
||||
renderImageTaskCtlChan: make(chan renderImageControlChanItem, 500),
|
||||
renderChan: make(chan []byte, 500),
|
||||
},
|
||||
}
|
||||
//保存连接
|
||||
|
@ -350,6 +350,6 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) {
|
|||
case constants.WEBSOCKET_REQUEST_REUSE_LAST_CONNECT:
|
||||
w.reuseLastConnect(d)
|
||||
default:
|
||||
|
||||
logx.Error("未知消息类型:", parseInfo.T)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,8 @@ import (
|
|||
// 云渲染属性
|
||||
type renderProperty struct {
|
||||
renderImageTask map[string]*renderTask //需要渲染的图片任务 key是taskId val 是renderId
|
||||
renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增移除的控制通道
|
||||
renderChan chan []byte //渲染的缓冲队列
|
||||
}
|
||||
type renderTask struct {
|
||||
RenderId string //渲染id(前端传的)
|
||||
CombineBeginTime int64 //合图开始时间
|
||||
CombineEndTime int64 //合图结束时间
|
||||
UnityRenderBeginTime int64 //发送给unity时间
|
||||
UnityRenderEndTime int64 //unity回调结果时间
|
||||
renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增/回调结果移除任务/更新渲染耗时属性的控制通道(由于任务map无法读写并发)
|
||||
renderChan chan []byte //渲染消息入口的缓冲队列
|
||||
}
|
||||
|
||||
// 渲染任务新增移除的控制通道的数据
|
||||
|
@ -40,6 +33,15 @@ type renderImageControlChanItem struct {
|
|||
TaskProperty renderTask //渲染任务的属性
|
||||
}
|
||||
|
||||
// 渲染任务属性
|
||||
type renderTask struct {
|
||||
RenderId string //渲染id(前端传的)
|
||||
CombineBeginTime int64 //合图开始时间
|
||||
CombineEndTime int64 //合图结束时间
|
||||
UnityRenderBeginTime int64 //发送给unity时间
|
||||
UnityRenderEndTime int64 //unity回调结果时间
|
||||
}
|
||||
|
||||
// 发送到渲染缓冲池
|
||||
func (w *wsConnectItem) sendToRenderChan(data []byte) {
|
||||
select {
|
||||
|
@ -222,7 +224,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||
}
|
||||
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
|
||||
if err != nil {
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("接口合图错误,产品id:%d", info.RenderData.ProductId)))
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("接口合图错误,产品id:%d,模板id:%d", info.RenderData.ProductId, productTemplate.Id)))
|
||||
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user