go_dreamfactory/modules/gateway/configure_comp.go
2022-08-18 15:09:34 +08:00

43 lines
986 B
Go

package gateway
import (
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/lego/core"
)
const (
game_msgdistrib = "game_msgdistrib.json"
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
}
// Init 组件初始化接口
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.ModuleCompBase.Init(service, module, comp, options)
this.LoadConfigure(game_msgdistrib, cfg.NewGameMsgdistrib)
return
}
// GetMsgDistribute 获取消息分发规则读取配置表
func (this *configureComp) GetMsgDistribute(msgid string) (rule string, ok bool) {
var (
err error
v interface{}
item *cfg.GameMsgdistribData
)
if v, err = this.GetConfigure(game_msgdistrib); err != nil {
ok = false
return
} else {
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid]; ok {
rule = item.Routrules
}
}
return
}