fix
This commit is contained in:
parent
88a59bbdea
commit
e25cc97ea0
|
@ -166,13 +166,12 @@ func (w *wsConnectItem) heartbeat() {
|
|||
case <-w.closeChan:
|
||||
return
|
||||
default:
|
||||
|
||||
}
|
||||
//发送心跳信息
|
||||
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
|
||||
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)
|
||||
w.close()
|
||||
return
|
||||
//发送心跳信息
|
||||
if err := w.conn.WriteMessage(websocket.TextMessage, b); err != nil {
|
||||
logx.Error("发送心跳信息异常,关闭连接:", w.flag, err)
|
||||
w.close()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,17 +209,16 @@ func (w *wsConnectItem) readLoop() {
|
|||
case <-w.closeChan: //如果关闭了
|
||||
return
|
||||
default:
|
||||
|
||||
_, data, err := w.conn.ReadMessage()
|
||||
if err != nil {
|
||||
logx.Error("接受信息错误:", err)
|
||||
//关闭连接
|
||||
w.close()
|
||||
return
|
||||
}
|
||||
//消息传入缓冲通道
|
||||
w.inChan <- data
|
||||
}
|
||||
_, data, err := w.conn.ReadMessage()
|
||||
if err != nil {
|
||||
logx.Error("接受信息错误:", err)
|
||||
//关闭连接
|
||||
w.close()
|
||||
return
|
||||
}
|
||||
//消息传入缓冲通道
|
||||
w.inChan <- data
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +262,7 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) {
|
|||
switch parseInfo.T {
|
||||
//图片渲染
|
||||
case constants.WEBSOCKET_RENDER_IMAGE:
|
||||
w.SendToCloudRender([]byte(parseInfo.D))
|
||||
go w.SendToCloudRender([]byte(parseInfo.D))
|
||||
default:
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fusenapi/server/websocket/internal/types"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 渲染请求数据处理发送云渲染服务处理
|
||||
|
@ -14,12 +15,22 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) {
|
|||
return
|
||||
}
|
||||
logx.Info("收到请求云渲染图片数据:", renderImageData)
|
||||
timer := time.NewTimer(time.Second * 10)
|
||||
//把需要渲染的图片任务加进去
|
||||
for _, v := range renderImageData {
|
||||
key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId)
|
||||
w.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||
Option: 1,
|
||||
Key: key,
|
||||
select {
|
||||
case <-w.closeChan: //连接关闭了
|
||||
return
|
||||
case <-timer.C: //10秒超时了
|
||||
return
|
||||
default:
|
||||
//加入渲染任务
|
||||
key := w.getRenderImageMapKey(v.ProductId, v.SizeId, v.TemplateId)
|
||||
w.renderImageTaskCtlChan <- renderImageControlChanItem{
|
||||
Option: 1,
|
||||
Key: key,
|
||||
}
|
||||
// TODO 数据发送给云渲染服务器
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user