feat 稳定300人

This commit is contained in:
2025-12-17 09:54:24 +08:00
parent 4983638c19
commit 0274262591
16 changed files with 467 additions and 234 deletions

View File

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