feat 改名

This commit is contained in:
2025-12-15 11:29:27 +08:00
parent f511364984
commit 4983638c19
27 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package ws_handler
import (
"sync"
)
var UserMgr *userManager
type userManager struct {
userMap map[int]*Client
sync.RWMutex
}
func init() {
UserMgr = &userManager{
userMap: make(map[int]*Client),
}
}
func (m *userManager) Add(uid int, client *Client) {
m.Lock()
defer m.Unlock()
m.userMap[uid] = client
}
func (m *userManager) Delete(uid int) {
m.Lock()
defer m.Unlock()
delete(m.userMap, uid)
}
func (m *userManager) GetAll() map[int]*Client {
m.RLock()
defer m.RUnlock()
return m.userMap
}
func (m *userManager) GetByUID(uid int) *Client {
m.RLock()
defer m.RUnlock()
return m.userMap[uid]
}