websotckt
This commit is contained in:
@@ -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中的客户端
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user