package base import ( "mongo.games.com/game/protocol/webapi" "mongo.games.com/goserver/core/logger" ) var PlatformConfigSingleton = &PlatformConfigMgr{ Platforms: make(map[string]*PlatformConfig), } type PlatformConfig struct { PlayerPool *webapi.PlayerPool GameConfig *webapi.GameConfig } type PlatformConfigMgr struct { Platforms map[string]*PlatformConfig //key 是平台标记 } func (this *PlatformConfigMgr) Get(plt string) *PlatformConfig { ret, ok := this.Platforms[plt] if !ok { ret = new(PlatformConfig) this.Platforms[plt] = ret } return ret } func (this *PlatformConfigMgr) Update(config any) { if config == nil { return } switch v := config.(type) { case *webapi.PlayerPool: this.Get(v.GetPlatform()).PlayerPool = v case *webapi.GameConfig: this.Get(v.GetPlatform()).GameConfig = v default: logger.Logger.Error("Update config type error") } }