go_dreamfactory/modules/gateway/configure_comp.go

50 lines
1.2 KiB
Go

package gateway
import (
"fmt"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"strings"
"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.MCompConfigure.Init(service, module, comp, options)
this.LoadConfigure(game_msgdistrib, cfg.NewGameMsgdistrib)
return
}
// GetMsgDistribute 获取消息分发规则读取配置表
func (this *configureComp) GetMsgDistribute(msgmid, msguid string) (rule string, ok bool) {
var (
item *cfg.GameMsgdistribData
)
if v, err := this.GetConfigure(game_msgdistrib); err == nil {
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgmid]; ok && item.Open {
rule = item.Routrules
return
} else {
msgid := strings.ToLower(fmt.Sprintf("%s.%s", msgmid, msguid))
if item, ok = v.(*cfg.GameMsgdistrib).GetDataMap()[msgid]; ok && item.Open {
rule = item.Routrules
return
}
}
}
ok = false
return
}