go_dreamfactory/modules/chat/configure.go
2022-08-18 15:09:34 +08:00

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.NewGameChatChannel)
this.LoadConfigure(game_chatsystem, cfg.NewGameChatSystem)
this.LoadConfigure(game_chatchannelcom, cfg.NewGameChatChannelCom)
return
}
//获取自动加入频道 任务限制
func (this *configureComp) GetAutoIntoChannelMax() (max int32, err error) {
var (
v interface{}
configure *cfg.GameChatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GameChatChannelCom).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.GamechatChannelComData channel_allocation_max:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChanageChannelMax() (max int32, err error) {
var (
v interface{}
configure *cfg.GameChatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GameChatChannelCom).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.GamechatChannelComData channel_switching_max:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChannelRecordMax() (max int32, err error) {
var (
v interface{}
configure *cfg.GameChatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GameChatChannelCom).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.GamechatChannelComData max_chat:%v", v)
}
}
return
}
//获取手动加入频道 任务限制
func (this *configureComp) GetChannelReadRecordNum() (max int32, err error) {
var (
v interface{}
configure *cfg.GameChatChannelComData
ok bool
)
if v, err = this.GetConfigure(game_chatchannelcom); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GameChatChannelCom).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.GamechatChannelComData max_chat:%v", v)
}
}
return
}