完善服务器

This commit is contained in:
2025-07-01 00:08:27 +08:00
parent b45eb83fe4
commit 7c2c32a31a
37 changed files with 1307 additions and 160 deletions

View File

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