package timer import ( "go_dreamfactory/comm" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/log" ) /* 模块名:定时任务 描述:处理区服集群下需要做的一些定时任务 开发:李伟 */ func NewModule() core.IModule { m := new(Timer) return m } type Timer struct { cbase.ModuleBase options *Options service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 chat *ChatComp //俩天系统定时任务 //season *SeasonPagoda forum *ForumComp arena *ArenaComp } //模块名 func (this *Timer) GetType() core.M_Modules { return comm.ModuleTimer } // NewOptions 模块自定义参数 func (this *Timer) NewOptions() (options core.IModuleOptions) { return new(Options) } //模块初始化接口 注册用户创建角色事件 func (this *Timer) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) this.service = service.(base.IRPCXService) this.options = options.(*Options) return } func (this *Timer) Start() (err error) { err = this.ModuleBase.Start() return } func (this *Timer) OnInstallComp() { this.ModuleBase.OnInstallComp() this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) //this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) } //日志 func (this *Timer) Enabled(lvl log.Loglevel) bool { return this.options.GetLog().Enabled(lvl) } func (this *Timer) SetName(name string) { this.options.GetLog().SetName(name) } //日志接口 func (this *Timer) Debug(msg string, args ...log.Field) { this.options.GetLog().Debug(msg, args...) } func (this *Timer) Info(msg string, args ...log.Field) { this.options.GetLog().Info(msg, args...) } func (this *Timer) Print(msg string, args ...log.Field) { this.options.GetLog().Print(msg, args...) } func (this *Timer) Warn(msg string, args ...log.Field) { this.options.GetLog().Warn(msg, args...) } func (this *Timer) Error(msg string, args ...log.Field) { this.options.GetLog().Error(msg, args...) } func (this *Timer) Panic(msg string, args ...log.Field) { this.options.GetLog().Panic(msg, args...) } func (this *Timer) Fatal(msg string, args ...log.Field) { this.options.GetLog().Fatal(msg, args...) } func (this *Timer) Debugf(format string, args ...interface{}) { this.options.GetLog().Debugf(format, args...) } func (this *Timer) Infof(format string, args ...interface{}) { this.options.GetLog().Infof(format, args...) } func (this *Timer) Printf(format string, args ...interface{}) { this.options.GetLog().Printf(format, args...) } func (this *Timer) Warnf(format string, args ...interface{}) { this.options.GetLog().Warnf(format, args...) } func (this *Timer) Errorf(format string, args ...interface{}) { this.options.GetLog().Errorf(format, args...) } func (this *Timer) Fatalf(format string, args ...interface{}) { this.options.GetLog().Fatalf(format, args...) } func (this *Timer) Panicf(format string, args ...interface{}) { this.options.GetLog().Panicf(format, args...) } func (this *Timer) Debugln(args ...interface{}) { this.options.GetLog().Debugln(args...) } func (this *Timer) Infoln(args ...interface{}) { this.options.GetLog().Infoln(args...) } func (this *Timer) Println(args ...interface{}) { this.options.GetLog().Println(args...) } func (this *Timer) Warnln(args ...interface{}) { this.options.GetLog().Warnln(args...) } func (this *Timer) Errorln(args ...interface{}) { this.options.GetLog().Errorln(args...) } func (this *Timer) Fatalln(args ...interface{}) { this.options.GetLog().Fatalln(args...) } func (this *Timer) Panicln(args ...interface{}) { this.options.GetLog().Panicln(args...) }