diff --git a/bin/bulid_linux.sh b/bin/build_linux.sh old mode 100644 new mode 100755 similarity index 100% rename from bin/bulid_linux.sh rename to bin/build_linux.sh diff --git a/bin/gateway b/bin/gateway deleted file mode 100755 index d77c38ba8..000000000 Binary files a/bin/gateway and /dev/null differ diff --git a/bin/mainte b/bin/mainte deleted file mode 100755 index 776150e5c..000000000 Binary files a/bin/mainte and /dev/null differ diff --git a/bin/stup.sh b/bin/stup.sh index 26c221631..2cfde666f 100755 --- a/bin/stup.sh +++ b/bin/stup.sh @@ -25,7 +25,7 @@ } stop(){ - echo "stopping..." + echo "stopping $SERVICE..." kill -9 `cat $SERVICE.pid` if [ $? -ne 0 ] then @@ -56,4 +56,4 @@ *) echo "Usage: $0 {start|stop|restart|status}" ;; esac - exit 0 \ No newline at end of file + exit 0 diff --git a/bin/worker b/bin/worker deleted file mode 100755 index 52667cfd3..000000000 Binary files a/bin/worker and /dev/null differ diff --git a/comm/const.go b/comm/const.go index 5ff2c5b58..c362064c0 100644 --- a/comm/const.go +++ b/comm/const.go @@ -48,14 +48,17 @@ const ( //RPC服务接口定义处 const ( //Rpc - Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由 - Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id - Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id - Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息 - Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息 - Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息 - Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 - Rpc_NoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 + //Gateway + Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由 + Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id + Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id + Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息 + Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息 + Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息 + Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 + Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 + //Chat + Rpc_ReleaseSystemMessage core.Rpc_Key = "Rpc_ReleaseSystemMessage" //发布系统消息 ) //事件类型定义处 diff --git a/modules/comp_gate.go b/modules/comp_gate.go index 135938dae..0a3fbb23f 100644 --- a/modules/comp_gate.go +++ b/modules/comp_gate.go @@ -100,13 +100,6 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) return } - // if agrType.Kind() != reflect.Ptr { - // return - // } - // if !this.isExportedOrBuiltinType(agrType) { - // return - // } - if mtype.NumOut() != 2 { log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) return diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 206e69eff..e110faf09 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -41,11 +41,18 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) code = pb.ErrorCode_EquipmentOnFoundEquipment return } + if equipments[i].HeroId != "" { //装备已经有宿主了 + code = pb.ErrorCode_ReqParameterError + return + } + if confs[i], err = this.module.configure.GetEquipmentConfigureById(equipments[i].CId); err != nil { log.Errorf("Equip_Check err:%v", err) code = pb.ErrorCode_EquipmentOnFoundEquipment 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 err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { - log.Errorf("Equip err%v", err) - code = pb.ErrorCode_SystemError - return - } + if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code != pb.ErrorCode_Success { + log.Errorf("Equip ModuleHero UpdateEquipment code%v", code) + 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}) return diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 6aeb48fa6..a36c5bf0f 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -44,7 +44,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) { this.agents.Delete(a.SessionId()) if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关 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(), ServiceTag: this.service.GetTag(), 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) } //推送跨服集群处理 - 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(), ServiceTag: this.service.GetTag(), GatewayServiceId: this.service.GetId(), diff --git a/modules/gm/api.go b/modules/gm/api.go index 6e140a486..2ec464dd4 100644 --- a/modules/gm/api.go +++ b/modules/gm/api.go @@ -4,6 +4,9 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "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.module = module.(*GM) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)) - this.gin.POST("/register", this.Register) - this.gin.GET("/serverlist", this.ServerList) - this.gin.GET("/createnotify", this.CreateNotify) + this.suitableMethods() //发射注册api 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))) + } +} diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index af6455cdc..013741c34 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -84,8 +84,8 @@ func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, //组件启动时注册rpc服务监听 func (this *SCompGateRoute) Start() (err error) { - this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 - this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知 + this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 + this.service.RegisterFunctionName(string(comm.Rpc_GatewayNoticeUserClose), this.NoticeUserClose) //注册用户离线通知 err = this.ServiceCompBase.Start() return }