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