refactor(entity): 重构 ClientData 结构体并添加同步锁
- 在 ClientData 中添加 sync.Mutex 以确保并发安全 - 实现 SetPlayer 和 GetPlayer 等方法来封装 player 字段的操作 - 更新相关代码以使用新的 ClientData 结构和方法
This commit is contained in:
@@ -50,7 +50,13 @@ func (s *LoginService) GetSessionId(accountID uint) (string, string, error) {
|
||||
// /t1.
|
||||
// 以上过程只需全局一次,且应在生成ID之前完成。
|
||||
}
|
||||
func (s *LoginService) SetServerID(OnlineID uint32, Port uint16) error {
|
||||
func (s *LoginService) SetServerID(OnlineID uint32, Port uint16, t *struct {
|
||||
Kick func(int32) error
|
||||
|
||||
RegisterLogic func(int32) error
|
||||
UserLogin func(int32, int32) error
|
||||
UserLogout func(int32, int32) error
|
||||
}) error {
|
||||
|
||||
m := cool.DBM(s.Model).Where("online_id", OnlineID)
|
||||
|
||||
@@ -65,7 +71,9 @@ func (s *LoginService) SetServerID(OnlineID uint32, Port uint16) error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
var tttt model.ServerList
|
||||
record.Struct(&tttt)
|
||||
//t.Quit(int32(tttt.Port))
|
||||
_, err = m.Data(&model.ServerList{OnlineID: OnlineID, Port: Port}).Where("online_id", OnlineID).Update()
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user