websotckt

This commit is contained in:
苏尹岚
2020-11-11 14:03:39 +08:00
parent f82b71332e
commit bbff9d2e4f

View File

@@ -92,7 +92,6 @@ func (c *EventController) TestWebsocket() {
msgMap = make(map[int]*model.ImMessageRecord)
groupID int
)
fmt.Println("test1,userID", userID)
//将当前客户端放入map中
messageGroups, _ := dao.GetUserMessageGroups(dao.GetDB(), userID)
for _, v := range messageGroups {
@@ -127,9 +126,11 @@ func (c *EventController) TestWebsocket() {
}
}
wsList := clients[groupID]
clients[groupID] = clients[groupID][0:0]
clients[groupID] = append(clients[groupID], wsList[0:index]...)
clients[groupID] = append(clients[groupID], wsList[index+1:len(wsList)]...)
if len(wsList) > 0 {
clients[groupID] = clients[groupID][0:0]
clients[groupID] = append(clients[groupID], wsList[0:index]...)
clients[groupID] = append(clients[groupID], wsList[index+1:len(wsList)]...)
}
// delete(clients, ws) //删除map中的客户端
break //结束循环
} else {
@@ -170,9 +171,11 @@ func handleMessages() {
}
}
wsList := clients[groupID]
clients[groupID] = clients[groupID][0:0]
clients[groupID] = append(clients[groupID], wsList[0:index]...)
clients[groupID] = append(clients[groupID], wsList[index+1:len(wsList)]...)
if len(wsList) > 0 {
clients[groupID] = clients[groupID][0:0]
clients[groupID] = append(clients[groupID], wsList[0:index]...)
clients[groupID] = append(clients[groupID], wsList[index+1:len(wsList)]...)
}
// delete(clients, client) //删除map中的客户端
}
}