aa
This commit is contained in:
@@ -45,7 +45,7 @@ func init() {
|
||||
clientsHeart := make(map[string]*websocket.Conn)
|
||||
wsClient.Clients = clients
|
||||
wsClient.ClientsHeart = clientsHeart
|
||||
wsClient = new(sync.RWMutex)
|
||||
wsClient.s = new(sync.RWMutex)
|
||||
go handleMessages()
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func ImMessage(userID string, ws *websocket.Conn) (err error) {
|
||||
if len(messageGroups) == 0 {
|
||||
return
|
||||
}
|
||||
wsClient.Lock()
|
||||
wsClient.s.Lock()
|
||||
clientUser[userID] = ws
|
||||
wsClient.ClientsHeart[userID] = ws
|
||||
for _, v := range messageGroups {
|
||||
@@ -110,7 +110,7 @@ func ImMessage(userID string, ws *websocket.Conn) (err error) {
|
||||
wsClient.Clients[v.GroupID] = clientUser
|
||||
}
|
||||
}
|
||||
wsClient.Unlock()
|
||||
wsClient.s.Unlock()
|
||||
globals.SugarLogger.Debugf("userID :%v ,clients :%v", userID, utils.Format4Output(wsClient.Clients, false))
|
||||
|
||||
var s *model.ImMessageRecord
|
||||
@@ -173,9 +173,9 @@ func ImMessage(userID string, ws *websocket.Conn) (err error) {
|
||||
}
|
||||
|
||||
func GetOnlineUserCount() (count int) {
|
||||
wsClient.RLock()
|
||||
wsClient.s.RLock()
|
||||
count = len(wsClient.ClientsHeart)
|
||||
wsClient.RUnlock()
|
||||
wsClient.s.RUnlock()
|
||||
return count
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user