56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package mgolog
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/base"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/core/cbase"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func NewModule() core.IModule {
|
|
m := new(MgoLog)
|
|
return m
|
|
}
|
|
|
|
type MgoLog struct {
|
|
cbase.ModuleBase
|
|
db_comp *DB_Comp
|
|
service base.IRPCXService
|
|
}
|
|
|
|
func (this *MgoLog) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
|
return
|
|
}
|
|
this.service = service.(base.IRPCXService)
|
|
return
|
|
}
|
|
|
|
func (this *MgoLog) GetType() core.M_Modules {
|
|
return comm.ModuleMgoLog
|
|
}
|
|
|
|
func (this *MgoLog) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.db_comp = this.RegisterComp(new(DB_Comp)).(*DB_Comp)
|
|
}
|
|
|
|
func (this *MgoLog) Start() (err error) {
|
|
if err = this.ModuleBase.Start(); err != nil {
|
|
return
|
|
}
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = this.service.RegisterFunctionName(string(comm.Rpc_GatewayNoticeUserClose), this.NoticeUserClose) //注册用户离线通知
|
|
return
|
|
}
|
|
|
|
// 离线通知
|
|
func (this *MgoLog) NoticeUserClose(ctx context.Context, args *pb.NoticeUserCloseReq, reply *pb.RPCMessageReply) error {
|
|
this.db_comp.PushUserTask(args.UserId)
|
|
return nil
|
|
}
|