This commit is contained in:
meixiongfeng 2022-07-22 15:53:46 +08:00
commit 90675a76d7
11 changed files with 61 additions and 30 deletions

0
bin/bulid_linux.sh → bin/build_linux.sh Normal file → Executable file
View File

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@
} }
stop(){ stop(){
echo "stopping..." echo "stopping $SERVICE..."
kill -9 `cat $SERVICE.pid` kill -9 `cat $SERVICE.pid`
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then

Binary file not shown.

View File

@ -48,14 +48,17 @@ const (
//RPC服务接口定义处 //RPC服务接口定义处
const ( //Rpc const ( //Rpc
Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由 //Gateway
Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由
Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id
Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息 Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id
Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息 Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息
Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息 Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息
Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息
Rpc_NoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接
Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线
//Chat
Rpc_ReleaseSystemMessage core.Rpc_Key = "Rpc_ReleaseSystemMessage" //发布系统消息
) )
//事件类型定义处 //事件类型定义处

View File

@ -100,13 +100,6 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me
log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname)
return return
} }
// if agrType.Kind() != reflect.Ptr {
// return
// }
// if !this.isExportedOrBuiltinType(agrType) {
// return
// }
if mtype.NumOut() != 2 { if mtype.NumOut() != 2 {
log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname)
return return

View File

@ -41,11 +41,18 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
code = pb.ErrorCode_EquipmentOnFoundEquipment code = pb.ErrorCode_EquipmentOnFoundEquipment
return return
} }
if equipments[i].HeroId != "" { //装备已经有宿主了
code = pb.ErrorCode_ReqParameterError
return
}
if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil { if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil {
log.Errorf("Equip_Check err:%v", err) log.Errorf("Equip_Check err:%v", err)
code = pb.ErrorCode_EquipmentOnFoundEquipment code = pb.ErrorCode_EquipmentOnFoundEquipment
return return
} }
} else {
equipments[i] = nil
} }
} }
//获取英雄数据 //获取英雄数据
@ -113,12 +120,15 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq)
} }
} }
//更新装备数据加成 //更新装备数据加成
if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code == pb.ErrorCode_Success { if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code != pb.ErrorCode_Success {
if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { log.Errorf("Equip ModuleHero UpdateEquipment code%v", code)
log.Errorf("Equip err%v", err) return
code = pb.ErrorCode_SystemError }
return //同步数据
} if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
log.Errorf("Equip err%v", err)
code = pb.ErrorCode_SystemError
return
} }
session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment}) session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment})
return return

View File

@ -44,7 +44,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) {
this.agents.Delete(a.SessionId()) this.agents.Delete(a.SessionId())
if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关 if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{ if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{
Ip: a.IP(), Ip: a.IP(),
ServiceTag: this.service.GetTag(), ServiceTag: this.service.GetTag(),
GatewayServiceId: this.service.GetId(), GatewayServiceId: this.service.GetId(),
@ -54,7 +54,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) {
log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err) log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err)
} }
//推送跨服集群处理 //推送跨服集群处理
if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{ if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{
Ip: a.IP(), Ip: a.IP(),
ServiceTag: this.service.GetTag(), ServiceTag: this.service.GetTag(),
GatewayServiceId: this.service.GetId(), GatewayServiceId: this.service.GetId(),

View File

@ -4,6 +4,9 @@ import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/gin" "go_dreamfactory/lego/sys/gin"
"go_dreamfactory/lego/sys/gin/engine"
"reflect"
"strings"
) )
/* /*
@ -22,8 +25,30 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
this.options = options.(*Options) this.options = options.(*Options)
this.module = module.(*GM) this.module = module.(*GM)
this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port))
this.gin.POST("/register", this.Register) this.suitableMethods() //发射注册api
this.gin.GET("/serverlist", this.ServerList)
this.gin.GET("/createnotify", this.CreateNotify)
return return
} }
func (this *Api_Comp) suitableMethods() {
typ := reflect.TypeOf(this)
vof := reflect.ValueOf(this)
for m := 0; m < typ.NumMethod(); m++ {
method := typ.Method(m)
mname := method.Name
mtype := method.Type
if method.PkgPath != "" {
continue
}
if mtype.NumIn() != 2 {
continue
}
context := mtype.In(1)
if context.String() != "*engine.Context" {
continue
}
if mtype.NumOut() != 0 {
continue
}
this.gin.POST(strings.ToLower(mname), vof.MethodByName(mname).Interface().(func(*engine.Context)))
}
}

View File

@ -84,8 +84,8 @@ func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp,
//组件启动时注册rpc服务监听 //组件启动时注册rpc服务监听
func (this *SCompGateRoute) Start() (err error) { func (this *SCompGateRoute) Start() (err error) {
this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口
this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知 this.service.RegisterFunctionName(string(comm.Rpc_GatewayNoticeUserClose), this.NoticeUserClose) //注册用户离线通知
err = this.ServiceCompBase.Start() err = this.ServiceCompBase.Start()
return return
} }