refactor(entity): 重构 ClientData 结构体并添加同步锁

- 在 ClientData 中添加 sync.Mutex 以确保并发安全
- 实现 SetPlayer 和 GetPlayer 等方法来封装 player 字段的操作
- 更新相关代码以使用新的 ClientData 结构和方法
This commit is contained in:
2025-07-06 22:58:39 +08:00
parent 53da82df82
commit 666557416d
9 changed files with 142 additions and 49 deletions

View File

@@ -71,15 +71,15 @@ func Start(serverid uint32) {
log.Fatalf("Failed to determine port: %v", err)
}
go func() {
t := rpc.StartClient(uint16(serverid), controller.Maincontroller)
// go func() {
t := rpc.StartClient(uint16(serverid), controller.Maincontroller)
controller.Maincontroller.RPCClient = *t //将RPC赋值Start
controller.Maincontroller.Port = serverid //赋值服务器ID
}()
controller.Maincontroller.RPCClient = *t //将RPC赋值Start
controller.Maincontroller.Port = serverid //赋值服务器ID
//}()
//go rpc.StartClient(uint16(serverid), &controller.Maincontroller)
service.NewLoginServiceService().SetServerID(serverid, gconv.Uint16(port))
service.NewLoginServiceService().SetServerID(serverid, gconv.Uint16(port), t)
socket.NewServer(socket.WithCORS(), socket.WithPort(port), socket.WithSocketHandler(head)).Start()
} else {