go_dreamfactory/modules/chat/configure.go

130 lines
3.5 KiB
Go

package chat
import (
"fmt"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/lego/core"
)
const (
game_chatchannel = "game_chatchannel.json"
game_chatsystem = "game_chatsystem.json"
game_chatservergroup = "game_chatservergroup.json"
game_chatchannelcom = "game_chatchannelcom.json"
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
module *Chat
}
//组件初始化接口
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.module = module.(*Chat)
this.LoadConfigure(game_chatchannel, cfg.NewGame_chatChannel)
this.LoadConfigure(game_chatsystem, cfg.NewGame_chatSystem)
this.LoadConfigure(game_chatchannelcom, cfg.NewGame_chatChannelCom)
return
}
//获取自动加入频道 任务限制
func (this *configureComp) GetAutoIntoChannelMax() (max int32, err error) {
var (
v interface{}
configure *cfg.Game_chatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["channel_allocation_max"]; !ok {
err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_allocation_max")
this.module.Errorf("err:%v", err)
return
}
max = configure.Value
if max <= 0 {
err = fmt.Errorf("cfg.Game_chatChannelComData channel_allocation_max:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChanageChannelMax() (max int32, err error) {
var (
v interface{}
configure *cfg.Game_chatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["channel_switching_max"]; !ok {
err = fmt.Errorf("cfg.Game_chatServerGroupData on found channel_switching_max")
this.module.Errorf("err:%v", err)
return
}
max = configure.Value
if max <= 0 {
err = fmt.Errorf("cfg.Game_chatChannelComData channel_switching_max:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChannelRecordMax() (max int32, err error) {
var (
v interface{}
configure *cfg.Game_chatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["max_chat"]; !ok {
err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat")
this.module.Errorf("err:%v", err)
return
}
max = configure.Value
if max <= 0 {
err = fmt.Errorf("cfg.Game_chatChannelComData max_chat:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChannelReadRecordNum() (max int32, err error) {
var (
v interface{}
configure *cfg.Game_chatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.Game_chatChannelCom).GetDataMap()["load_chat"]; !ok {
err = fmt.Errorf("cfg.Game_chatServerGroupData on found max_chat")
this.module.Errorf("err:%v", err)
return
}
max = configure.Value
if max <= 0 {
err = fmt.Errorf("cfg.Game_chatChannelComData max_chat:%v", v)
}
}
return
}