This commit is contained in:
laodaming 2023-08-22 18:37:49 +08:00
parent 7682843f3e
commit 3e7b4e9c4b
2 changed files with 30 additions and 5 deletions

View File

@ -146,6 +146,11 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User
//保存连接
mapConnPool.Store(uniqueId, ws)
go func() {
defer func() {
if err := recover(); err != nil {
logx.Error("set conn pool panic:", err)
}
}()
//把连接成功消息发回去
time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究)
ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId))
@ -241,6 +246,11 @@ func (w *wsConnectItem) close() {
// 读取出口缓冲池数据输出返回给浏览器端
func (w *wsConnectItem) writeLoop() {
defer func() {
if err := recover(); err != nil {
logx.Error("write loop panic:", err)
}
}()
for {
select {
case <-w.closeChan: //如果关闭了
@ -257,6 +267,11 @@ func (w *wsConnectItem) writeLoop() {
// 接受客户端发来的消息并写入入口缓冲池
func (w *wsConnectItem) readLoop() {
defer func() {
if err := recover(); err != nil {
logx.Error("read loop panic:", err)
}
}()
for {
select {
case <-w.closeChan: //如果关闭了
@ -280,6 +295,11 @@ func (w *wsConnectItem) readLoop() {
// 消费websocket入口数据池中的数据
func (w *wsConnectItem) sendLoop() {
defer func() {
if err := recover(); err != nil {
logx.Error("send loop panic:", err)
}
}()
for {
select {
case <-w.closeChan:

View File

@ -72,6 +72,11 @@ func (w *wsConnectItem) renderImage() {
// 消费渲染缓冲数据
func (w *wsConnectItem) consumeRenderCache(data []byte) {
defer func() {
if err := recover(); err != nil {
logx.Error("consumeRenderCache panic:", err)
}
}()
logx.Info("消费渲染数据:", string(data))
var renderImageData websocket_data.RenderImageReqMsg
if err := json.Unmarshal(data, &renderImageData); err != nil {
@ -164,11 +169,6 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
// 组装数据发送给unity
func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) error {
defer func() {
if err := recover(); err != nil {
logx.Error("assembleRenderData panic:", err)
}
}()
//获取产品第一个尺寸
productFirstSize, err := w.logic.svcCtx.AllModels.FsProductSize.GetProductFirstSize(w.logic.ctx, info.RenderData.ProductId)
if err != nil {
@ -407,6 +407,11 @@ func (w *wsConnectItem) modifyRenderTaskTimeConsuming(data renderImageControlCha
// 处理渲染任务的增加/删除/修改耗时属性任务map不能读写并发所以放在chan里面串行执行
func (w *wsConnectItem) operationRenderTask() {
defer func() {
if err := recover(); err != nil {
logx.Error("operation render task panic:", err)
}
}()
for {
select {
case <-w.closeChan: