This commit is contained in:
苏尹岚
2020-12-31 10:24:19 +08:00
parent eda0d50636
commit 6d66d1ec35

View File

@@ -37,6 +37,7 @@ const (
type WSClient struct {
Clients map[int]map[string]*websocket.Conn
ClientsHeart map[string]*websocket.Conn
s *sync.RWMutex
}
func init() {
@@ -99,6 +100,7 @@ func ImMessage(userID string, ws *websocket.Conn) (err error) {
if len(messageGroups) == 0 {
return
}
wsClient.s.Lock()
clientUser[userID] = ws
wsClient.ClientsHeart[userID] = ws
for _, v := range messageGroups {
@@ -108,6 +110,7 @@ func ImMessage(userID string, ws *websocket.Conn) (err error) {
wsClient.Clients[v.GroupID] = clientUser
}
}
wsClient.s.Unlock()
globals.SugarLogger.Debugf("userID :%v ,clients :%v", userID, utils.Format4Output(wsClient.Clients, false))
var s *model.ImMessageRecord