package matchpool import ( "context" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" "go_dreamfactory/pb" ) /* 模块名:匹配池 开发:李伟 描述:集合项目中所有匹配玩法 */ type MatchPool struct { modules.ModuleBase service comm.IService pools *poolsComp } func NewModule() core.IModule { return &MatchPool{} } func (this *MatchPool) GetType() core.M_Modules { return comm.ModuleMatchPool } func (this *MatchPool) 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.(comm.IService) return } func (this *MatchPool) Start() (err error) { if err = this.ModuleBase.Start(); err != nil { return } this.service.RegisterFunctionName(string(comm.RPC_JoinMatchPools), this.JoinMatchPools) this.service.RegisterFunctionName(string(comm.RPC_CancelMatch), this.CancelMatch) return } func (this *MatchPool) OnInstallComp() { this.ModuleBase.OnInstallComp() this.pools = this.RegisterComp(new(poolsComp)).(*poolsComp) } //加入匹配池 func (this *MatchPool) JoinMatchPools(ctx context.Context, req *pb.JoinMatchPoolReq, resp *pb.JoinMatchPoolResp) { this.pools.joinPools(req) } //取消匹配 func (this *MatchPool) CancelMatch(ctx context.Context, req *pb.CancelMatchReq, resp *pb.CancelMatchResp) { this.pools.cancelMatch(req) } func (this *MatchPool) MatchNotice(req *pb.SuccMatchNoticeReq) { var ( err error ) if err = this.service.RpcCall(context.Background(), comm.Service_Worker, string(comm.RPC_SuccMatchNotice), req, &pb.RPCParkourMatchSuccResp{}, ); err != nil { this.Error("MatchNotice err!", log.Field{Key: "err", Value: err.Error()}) return } }