69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package modules
|
||
|
||
import (
|
||
"context"
|
||
"go_dreamfactory/comm"
|
||
"go_dreamfactory/lego/core"
|
||
"go_dreamfactory/lego/core/cbase"
|
||
"go_dreamfactory/lego/sys/log"
|
||
"go_dreamfactory/pb"
|
||
)
|
||
|
||
/*
|
||
模块 网关组件 接收处理用户传递消息
|
||
*/
|
||
type MCompMatch struct {
|
||
cbase.ModuleCompBase
|
||
service comm.IService //rpc服务对象
|
||
module core.IModule //当前业务模块
|
||
comp IMatchComp //网关组件自己
|
||
scomp comm.ISC_MatchComp
|
||
PoolName string
|
||
}
|
||
|
||
//组件初始化接口
|
||
func (this *MCompMatch) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||
this.ModuleCompBase.Init(service, module, comp, options)
|
||
this.service = service.(comm.IService)
|
||
this.module = module
|
||
this.comp = comp.(IMatchComp)
|
||
return
|
||
}
|
||
|
||
//组件启动接口,启动时将自己接收用户消息的处理函数注册到services/comp_gateroute.go 对象中
|
||
func (this *MCompMatch) Start() (err error) {
|
||
if err = this.ModuleCompBase.Start(); err != nil {
|
||
return
|
||
}
|
||
var comp core.IServiceComp
|
||
//注册远程路由
|
||
if comp, err = this.service.GetComp(comm.SC_ServiceMatchComp); err != nil {
|
||
return
|
||
}
|
||
this.scomp = comp.(comm.ISC_MatchComp)
|
||
this.scomp.RegisterMatchPool(this.PoolName, this.comp.MatchNotic)
|
||
return
|
||
}
|
||
|
||
func (this *MCompMatch) CancelMatch(uid string) (err error) {
|
||
err = this.service.RpcCall(
|
||
context.Background(),
|
||
comm.Service_Mainte,
|
||
string(comm.RPC_CancelMatch),
|
||
&pb.CancelMatchReq{
|
||
Poolname: this.PoolName,
|
||
Uid: uid,
|
||
},
|
||
&pb.JoinMatchPoolResp{})
|
||
if err != nil {
|
||
log.Errorln(err)
|
||
return
|
||
}
|
||
return
|
||
}
|
||
|
||
func (this *MCompMatch) MatchNotic(player map[string]interface{}) (err error) {
|
||
log.Errorf("module:%s no rewrite MatchNotic! ", this.module.GetType())
|
||
return
|
||
}
|