This commit is contained in:
laodaming 2023-09-07 09:58:28 +08:00
parent b3e51d31c3
commit 648a19cb8c

View File

@ -70,7 +70,7 @@ var (
//用户标识的连接(白板用户不存) //用户标识的连接(白板用户不存)
mapUserConnPool = make(map[string]map[string]struct{}) //key是user_id +"_"+guest_id val是个普通map存储这个用户的所有连接标识 mapUserConnPool = make(map[string]map[string]struct{}) //key是user_id +"_"+guest_id val是个普通map存储这个用户的所有连接标识
//用户标识的连接增删操作队列 //用户标识的连接增删操作队列
mapUserConnPoolCtlChan = make(chan userConnPoolCtlChanItem, 2000) userConnPoolCtlChan = make(chan userConnPoolCtlChanItem, 2000)
//每个websocket连接入口缓冲队列长度 //每个websocket连接入口缓冲队列长度
websocketInChanLen = 1000 websocketInChanLen = 1000
//每个websocket连接出口缓冲队列长度 //每个websocket连接出口缓冲队列长度
@ -230,7 +230,7 @@ func createUserConnPoolElement(userId, guestId int64, uniqueId string) {
option: 1, option: 1,
} }
select { select {
case mapUserConnPoolCtlChan <- data: case userConnPoolCtlChan <- data:
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
return return
@ -248,7 +248,7 @@ func deleteUserConnPoolElement(userId, guestId int64, uniqueId string) {
option: 0, option: 0,
} }
select { select {
case mapUserConnPoolCtlChan <- data: case userConnPoolCtlChan <- data:
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
return return
@ -265,7 +265,7 @@ func sendToOutChanByUserIndex(userId, guestId int64, message []byte) {
option: 2, option: 2,
} }
select { select {
case mapUserConnPoolCtlChan <- data: case userConnPoolCtlChan <- data:
return return
case <-time.After(time.Millisecond * 200): case <-time.After(time.Millisecond * 200):
return return
@ -287,7 +287,7 @@ func ConsumeUserPoolData(ctx context.Context) {
}() }()
for { for {
select { select {
case data := <-mapUserConnPoolCtlChan: case data := <-userConnPoolCtlChan:
key := getmapUserConnPoolUniqueId(data.userId, data.guestId) key := getmapUserConnPoolUniqueId(data.userId, data.guestId)
switch data.option { switch data.option {
case 2: //发送消息 case 2: //发送消息