Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-08-23 15:33:58 +08:00
commit de52fd3ad2

View File

@ -6,7 +6,6 @@ import (
"encoding/json" "encoding/json"
"fusenapi/constants" "fusenapi/constants"
"fusenapi/utils/auth" "fusenapi/utils/auth"
"fusenapi/utils/id_generator"
"fusenapi/utils/websocket_data" "fusenapi/utils/websocket_data"
"net/http" "net/http"
"sync" "sync"
@ -37,8 +36,6 @@ func NewDataTransferLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Data
} }
var ( var (
//全局websocketid生成器
websocketIdGenerator = id_generator.NewWebsocketId(1)
//临时缓存对象池 //临时缓存对象池
buffPool = sync.Pool{ buffPool = sync.Pool{
New: func() interface{} { New: func() interface{} {
@ -62,23 +59,23 @@ var (
} }
//websocket连接存储 //websocket连接存储
mapConnPool = sync.Map{} mapConnPool = sync.Map{}
//公共互斥锁 //公共互斥锁(复用连接标识用)
publicMutex sync.Mutex publicMutex sync.Mutex
) )
// 每个连接的连接基本属性 // 每个连接的连接基本属性
type wsConnectItem struct { type wsConnectItem struct {
conn *websocket.Conn //websocket的连接 conn *websocket.Conn //websocket的连接(基本属性)
logic *DataTransferLogic //logic logic *DataTransferLogic //logic(基本属性,用于获取上下文,配置或者操作数据库)
closeChan chan struct{} //ws连接关闭chan closeChan chan struct{} //ws连接关闭chan(基本属性)
isClose bool //是否已经关闭 isClose bool //是否已经关闭(基本属性)
uniqueId string //ws连接唯一标识 uniqueId string //ws连接唯一标识(基本属性)
inChan chan []byte //接受消息缓冲通道 inChan chan []byte //接受消息缓冲通道(基本属性)
outChan chan []byte //发送回客户端的消息 outChan chan []byte //发送回客户端的消息(基本属性)
mutex sync.Mutex //互斥锁 mutex sync.Mutex //互斥锁(关闭连接方法中用)
userId int64 //用户id userId int64 //用户id(基本属性)
guestId int64 //游客id guestId int64 //游客id(基本属性)
renderProperty renderProperty //扩展云渲染属性 renderProperty renderProperty //扩展云渲染属性(扩展属性)
} }
// 请求建立连接升级websocket协议 // 请求建立连接升级websocket协议