上传协议修改代码
This commit is contained in:
parent
ce2f052465
commit
6098f3edda
@ -16,8 +16,7 @@ import (
|
|||||||
type ISC_GateRouteComp interface {
|
type ISC_GateRouteComp interface {
|
||||||
core.IServiceComp
|
core.IServiceComp
|
||||||
ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error
|
ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error
|
||||||
RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method)
|
RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, reply reflect.Type, check, handle reflect.Method)
|
||||||
RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//游戏类资源类型
|
//游戏类资源类型
|
||||||
@ -35,8 +34,6 @@ type Autogenerated struct {
|
|||||||
D []interface{}
|
D []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HeroStarLvRatio int32 = 10 // 卡牌等级上限系数(星级*10)
|
HeroStarLvRatio int32 = 10 // 卡牌等级上限系数(星级*10)
|
||||||
)
|
)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"log"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -56,27 +57,27 @@ func (this *MCompGate) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.scomp = comp.(comm.ISC_GateRouteComp)
|
this.scomp = comp.(comm.ISC_GateRouteComp)
|
||||||
this.suitableMethods(reflect.TypeOf(this.comp))
|
this.suitableMethods()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//反射注册相关接口道services/comp_gateroute.go 对象中
|
//反射注册相关接口道services/comp_gateroute.go 对象中
|
||||||
func (this *MCompGate) suitableMethods(typ reflect.Type) {
|
func (this *MCompGate) suitableMethods() {
|
||||||
|
typ := reflect.TypeOf(this.comp)
|
||||||
for m := 0; m < typ.NumMethod(); m++ {
|
for m := 0; m < typ.NumMethod(); m++ {
|
||||||
method := typ.Method(m)
|
method := typ.Method(m)
|
||||||
this.reflectionRouteHandle(method)
|
this.reflectionRouteHandle(typ, method)
|
||||||
this.reflectionRouteCheck(method)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//反射注册路由处理函数
|
//反射注册路由处理函数
|
||||||
func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Method) {
|
||||||
mtype := method.Type
|
mtype := method.Type
|
||||||
mname := method.Name
|
mname := method.Name
|
||||||
if method.PkgPath != "" {
|
if method.PkgPath != "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if mtype.NumIn() != 4 {
|
if mtype.NumIn() != 5 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctxType := mtype.In(1)
|
ctxType := mtype.In(1)
|
||||||
@ -87,13 +88,21 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
|||||||
if !argType.Implements(typeOfMapStringIntface) {
|
if !argType.Implements(typeOfMapStringIntface) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
replyType := mtype.In(3)
|
agrType := mtype.In(3)
|
||||||
|
if agrType.Kind() != reflect.Ptr {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !this.isExportedOrBuiltinType(agrType) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
replyType := mtype.In(4)
|
||||||
if replyType.Kind() != reflect.Ptr {
|
if replyType.Kind() != reflect.Ptr {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !this.isExportedOrBuiltinType(replyType) {
|
if !this.isExportedOrBuiltinType(replyType) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if mtype.NumOut() != 1 {
|
if mtype.NumOut() != 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -101,45 +110,51 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
|||||||
if returnCodeType != typeOfErrorCode {
|
if returnCodeType != typeOfErrorCode {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), replyType, method)
|
|
||||||
|
//寻找校验函数
|
||||||
|
check, ok := typ.MethodByName(mname + "Check")
|
||||||
|
if !ok {
|
||||||
|
log.Panicf("反射注册用户处理函数错误 [%s-%s]没有对应的校验函数", this.module.GetType(), mname)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err := this.reflectionRouteCheck(check, agrType); err == nil {
|
||||||
|
this.scomp.RegisterRoute(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname)), reflect.ValueOf(this.comp), agrType, replyType, check, method)
|
||||||
|
} else {
|
||||||
|
log.Panicf("反射注册用户处理函数错误 [%s-%s]校验函数格式异常:%v", this.module.GetType(), mname, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//反射注册路由校验函数
|
//反射注册路由校验函数
|
||||||
func (this *MCompGate) reflectionRouteCheck(method reflect.Method) {
|
func (this *MCompGate) reflectionRouteCheck(method reflect.Method, msgtype reflect.Type) error {
|
||||||
mtype := method.Type
|
mtype := method.Type
|
||||||
mname := strings.Split(method.Name, "_")
|
|
||||||
if len(mname) != 2 || mname[1] != "Check" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if method.PkgPath != "" {
|
if method.PkgPath != "" {
|
||||||
return
|
return fmt.Errorf("method.PkgPath:%v", method.PkgPath)
|
||||||
}
|
}
|
||||||
if mtype.NumIn() != 3 {
|
if mtype.NumIn() != 3 {
|
||||||
return
|
return fmt.Errorf("mtype.NumIn():%v", mtype.NumIn())
|
||||||
}
|
}
|
||||||
ctxType := mtype.In(1)
|
ctxType := mtype.In(1)
|
||||||
if !ctxType.Implements(typeOfSession) {
|
if !ctxType.Implements(typeOfSession) {
|
||||||
return
|
return fmt.Errorf("ctxType:%T", ctxType)
|
||||||
}
|
}
|
||||||
replyType := mtype.In(2)
|
replyType := mtype.In(2)
|
||||||
if replyType.Kind() != reflect.Ptr {
|
if replyType != msgtype {
|
||||||
return
|
return fmt.Errorf("replyType:%T", replyType)
|
||||||
}
|
|
||||||
if !this.isExportedOrBuiltinType(replyType) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if mtype.NumOut() != 2 {
|
if mtype.NumOut() != 2 {
|
||||||
return
|
return fmt.Errorf("mtype.NumOut():%d", mtype.NumOut())
|
||||||
}
|
}
|
||||||
returnMapType := mtype.Out(0)
|
returnMapType := mtype.Out(0)
|
||||||
if !returnMapType.Implements(typeOfMapStringIntface) {
|
if !returnMapType.Implements(typeOfMapStringIntface) {
|
||||||
return
|
return fmt.Errorf("returnMapType:%T", returnMapType)
|
||||||
}
|
}
|
||||||
returnCodeType := mtype.Out(1)
|
returnCodeType := mtype.Out(1)
|
||||||
if returnCodeType != typeOfCode {
|
if returnCodeType != typeOfCode {
|
||||||
return
|
return fmt.Errorf("returnCodeType:%T", returnCodeType)
|
||||||
}
|
}
|
||||||
this.scomp.RegisterRouteCheck(fmt.Sprintf("%s.%s", this.module.GetType(), strings.ToLower(mname[0])), reflect.ValueOf(this.comp), replyType, method)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MCompGate) isExportedOrBuiltinType(t reflect.Type) bool {
|
func (this *MCompGate) isExportedOrBuiltinType(t reflect.Type) bool {
|
||||||
|
@ -134,7 +134,7 @@ func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs .
|
|||||||
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||||
}
|
}
|
||||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||||
err = this.InsertModelLogs(this.TableName, uid, data)
|
err = this.InsertModelLogs(this.TableName, uid, []interface{}{data})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,21 @@ import (
|
|||||||
/*
|
/*
|
||||||
装备模块 API
|
装备模块 API
|
||||||
*/
|
*/
|
||||||
type ApiComp struct {
|
type apiComp struct {
|
||||||
modules.MCompGate
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
module *Equipment
|
module *Equipment
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MCompGate.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.module = module.(*Equipment)
|
this.module = module.(*Equipment)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ApiComp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MCompGate.Start()
|
err = this.MCompGate.Start()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
errorCode pb.ErrorCode
|
errorCode pb.ErrorCode
|
||||||
@ -20,7 +20,7 @@ func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Eq
|
|||||||
equipments = make([]*pb.DB_Equipment, len(req.EquipmentId))
|
equipments = make([]*pb.DB_Equipment, len(req.EquipmentId))
|
||||||
for i, v := range req.EquipmentId {
|
for i, v := range req.EquipmentId {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||||
log.Errorf("Equip_Check err:%v", err)
|
log.Errorf("Equip_Check err:%v", err)
|
||||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||||
return
|
return
|
||||||
@ -46,7 +46,7 @@ func (this *ApiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Eq
|
|||||||
}
|
}
|
||||||
|
|
||||||
///英雄挂在装备
|
///英雄挂在装备
|
||||||
func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) {
|
func (this *apiComp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
confs []*cfg.Game_equipData
|
confs []*cfg.Game_equipData
|
||||||
@ -64,7 +64,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
|||||||
for i, v := range hero.EquipID {
|
for i, v := range hero.EquipID {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
if equipments[i] != nil && v != equipments[i].Id {
|
if equipments[i] != nil && v != equipments[i].Id {
|
||||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||||
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
@ -73,7 +73,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
|||||||
equipments[i].HeroId = hero.Id
|
equipments[i].HeroId = hero.Id
|
||||||
updatequipment = append(updatequipment, equipment, equipments[i])
|
updatequipment = append(updatequipment, equipment, equipments[i])
|
||||||
} else if equipments[i] == nil {
|
} else if equipments[i] == nil {
|
||||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||||
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
@ -96,7 +96,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success {
|
if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success {
|
||||||
if err = this.module.modelequipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
||||||
log.Errorf("Equip err%v", err)
|
log.Errorf("Equip err%v", err)
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *ApiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///获取用户装备列表
|
///获取用户装备列表
|
||||||
func (this *ApiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) {
|
func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_GetList_Req, resp *pb.Equipment_GetList_Resp) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
items []*pb.DB_Equipment
|
items []*pb.DB_Equipment
|
||||||
@ -23,7 +23,7 @@ func (this *ApiComp) Getlist(session comm.IUserSession, agrs map[string]interfac
|
|||||||
// session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items})
|
// session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_GetList_Resp{Equipments: items})
|
||||||
// }
|
// }
|
||||||
// }()
|
// }()
|
||||||
if items, err = this.module.modelequipment.QueryUserEquipments(session.GetUserId()); err != nil {
|
if items, err = this.module.modelEquipment.QueryUserEquipments(session.GetUserId()); err != nil {
|
||||||
log.Errorf("QueryUserPackReq err:%v", err)
|
log.Errorf("QueryUserPackReq err:%v", err)
|
||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
func (this *apiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
conf *cfg.Game_equipData
|
conf *cfg.Game_equipData
|
||||||
@ -24,7 +24,7 @@ func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_
|
|||||||
code.Code = pb.ErrorCode_ReqParameterError
|
code.Code = pb.ErrorCode_ReqParameterError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil {
|
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil {
|
||||||
log.Errorf("Equip_Check err:%v", err)
|
log.Errorf("Equip_Check err:%v", err)
|
||||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||||
return
|
return
|
||||||
@ -49,7 +49,7 @@ func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_
|
|||||||
}
|
}
|
||||||
|
|
||||||
///英雄挂在装备
|
///英雄挂在装备
|
||||||
func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) {
|
func (this *apiComp) Upgrade(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Upgrade_Req) (code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
conf *cfg.Game_equipData
|
conf *cfg.Game_equipData
|
||||||
@ -85,7 +85,7 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
|||||||
//叠加装备 拆分处理
|
//叠加装备 拆分处理
|
||||||
if equipment.IsInitialState && equipment.OverlayNum > 1 {
|
if equipment.IsInitialState && equipment.OverlayNum > 1 {
|
||||||
equipment.OverlayNum--
|
equipment.OverlayNum--
|
||||||
if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||||
"overlayNum": equipment.OverlayNum,
|
"overlayNum": equipment.OverlayNum,
|
||||||
"heroId": "",
|
"heroId": "",
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -97,24 +97,24 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
|||||||
equipment.Id = primitive.NewObjectID().Hex()
|
equipment.Id = primitive.NewObjectID().Hex()
|
||||||
equipment.IsInitialState = false
|
equipment.IsInitialState = false
|
||||||
equipment.OverlayNum = 1
|
equipment.OverlayNum = 1
|
||||||
if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
log.Errorf("Upgrade err:%v", err)
|
log.Errorf("Upgrade err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = this.module.modelequipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil {
|
if err = this.module.modelEquipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil {
|
||||||
log.Errorf("Upgrade err:%v", err)
|
log.Errorf("Upgrade err:%v", err)
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
equipment.IsInitialState = false
|
equipment.IsInitialState = false
|
||||||
if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
log.Errorf("Upgrade err:%v", err)
|
log.Errorf("Upgrade err:%v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||||
"lv": equipment.Lv,
|
"lv": equipment.Lv,
|
||||||
"mainEntry": equipment.MainEntry,
|
"mainEntry": equipment.MainEntry,
|
||||||
"adverbEntry": equipment.AdverbEntry,
|
"adverbEntry": equipment.AdverbEntry,
|
||||||
@ -136,7 +136,7 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
|||||||
for i, v := range hero.EquipID {
|
for i, v := range hero.EquipID {
|
||||||
if v != "" {
|
if v != "" {
|
||||||
if v != equipment.Id {
|
if v != equipment.Id {
|
||||||
if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||||
log.Errorf("Upgrade err:%v", err)
|
log.Errorf("Upgrade err:%v", err)
|
||||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||||
return
|
return
|
||||||
|
@ -17,12 +17,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
///背包配置管理组件
|
||||||
type ConfigureComp struct {
|
type configureComp struct {
|
||||||
modules.MCompConfigure
|
modules.MCompConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.ModuleCompBase.Init(service, module, comp, options)
|
this.ModuleCompBase.Init(service, module, comp, options)
|
||||||
this.LoadConfigure(game_equip, cfg.NewGame_equip)
|
this.LoadConfigure(game_equip, cfg.NewGame_equip)
|
||||||
this.LoadConfigure(equip_attrlibrary, cfg.NewGame_equipAttrlibrary)
|
this.LoadConfigure(equip_attrlibrary, cfg.NewGame_equipAttrlibrary)
|
||||||
@ -30,7 +30,7 @@ func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
//获取装备配置数据
|
||||||
func (this *ConfigureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) {
|
func (this *configureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
@ -49,7 +49,7 @@ func (this *ConfigureComp) GetEquipmentConfigure() (configure *cfg.Game_equip, e
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取装备配置数据
|
//获取装备配置数据
|
||||||
func (this *ConfigureComp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) {
|
func (this *configureComp) GetEquipmentConfigureById(equipmentId int32) (configure *cfg.Game_equipData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
@ -68,7 +68,7 @@ func (this *ConfigureComp) GetEquipmentConfigureById(equipmentId int32) (configu
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取装备属性表
|
//获取装备属性表
|
||||||
func (this *ConfigureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Game_equipAttrlibrary, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
@ -87,7 +87,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigure() (configure *cfg.Ga
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取属性词列表
|
//获取属性词列表
|
||||||
func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (configure *cfg.Game_equipAttrlibraryData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
@ -106,7 +106,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureByKey(key int32) (con
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取属性词列表
|
//获取属性词列表
|
||||||
func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) {
|
func (this *configureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (configure []*cfg.Game_equipAttrlibraryData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
)
|
)
|
||||||
@ -125,7 +125,7 @@ func (this *ConfigureComp) GetEquipmentAttrlibraryConfigureById(Id int32) (confi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取武器等级消耗表
|
//获取武器等级消耗表
|
||||||
func (this *ConfigureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) {
|
func (this *configureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game_equipIntensify, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
@ -144,7 +144,7 @@ func (this *ConfigureComp) GetEquipmentIntensifyConfigure() (configure *cfg.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
//获取武器等级消耗表
|
//获取武器等级消耗表
|
||||||
func (this *ConfigureComp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) {
|
func (this *configureComp) GetEquipmentIntensifyConfigureById(Id int32) (configure *cfg.Game_equipIntensifyData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
ok bool
|
ok bool
|
||||||
|
@ -15,13 +15,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
///装备 数据组件
|
///装备 数据组件
|
||||||
type ModelEquipmentComp struct {
|
type modelEquipmentComp struct {
|
||||||
modules.MCompModel
|
modules.MCompModel
|
||||||
module *Equipment
|
module *Equipment
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *ModelEquipmentComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
func (this *modelEquipmentComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||||
this.MCompModel.Init(service, module, comp, opt)
|
this.MCompModel.Init(service, module, comp, opt)
|
||||||
this.module = module.(*Equipment)
|
this.module = module.(*Equipment)
|
||||||
this.TableName = "equipment"
|
this.TableName = "equipment"
|
||||||
@ -33,21 +33,21 @@ func (this *ModelEquipmentComp) Init(service core.IService, module core.IModule,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//查询用户装备数据
|
//查询用户装备数据
|
||||||
func (this *ModelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) {
|
func (this *modelEquipmentComp) QueryUserEquipmentsById(uId, id string) (equipment *pb.DB_Equipment, err error) {
|
||||||
equipment = &pb.DB_Equipment{}
|
equipment = &pb.DB_Equipment{}
|
||||||
err = this.GetListObj(uId, id, equipment)
|
err = this.GetListObj(uId, id, equipment)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///查询用户的武器背包
|
///查询用户的武器背包
|
||||||
func (this *ModelEquipmentComp) QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) {
|
func (this *modelEquipmentComp) QueryUserEquipments(uId string) (equipments []*pb.DB_Equipment, err error) {
|
||||||
equipments = make([]*pb.DB_Equipment, 0)
|
equipments = make([]*pb.DB_Equipment, 0)
|
||||||
err = this.GetList(uId, &equipments)
|
err = this.GetList(uId, &equipments)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
///查询目标卡片数量
|
///查询目标卡片数量
|
||||||
func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) {
|
func (this *modelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) {
|
||||||
var (
|
var (
|
||||||
equipments []*pb.DB_Equipment
|
equipments []*pb.DB_Equipment
|
||||||
err error
|
err error
|
||||||
@ -65,7 +65,7 @@ func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加装备
|
//添加装备
|
||||||
func (this *ModelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) {
|
func (this *modelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32) (err error) {
|
||||||
var (
|
var (
|
||||||
configure *cfg.Game_equip
|
configure *cfg.Game_equip
|
||||||
equipments []*pb.DB_Equipment
|
equipments []*pb.DB_Equipment
|
||||||
@ -115,7 +115,7 @@ func (this *ModelEquipmentComp) AddEquipments(uId string, cIds map[int32]uint32)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新武器挂载信息
|
//更新武器挂载信息
|
||||||
func (this *ModelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) {
|
func (this *modelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_Equipment) (err error) {
|
||||||
for _, v := range equipments {
|
for _, v := range equipments {
|
||||||
if err = this.ChangeList(uid, v.Id, map[string]interface{}{
|
if err = this.ChangeList(uid, v.Id, map[string]interface{}{
|
||||||
"heroId": v.HeroId,
|
"heroId": v.HeroId,
|
||||||
@ -128,7 +128,7 @@ func (this *ModelEquipmentComp) UpdateByHeroId(uid string, equipments ...*pb.DB_
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创建新的武器对象
|
//创建新的武器对象
|
||||||
func (this *ModelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) {
|
func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipData, num uint32) (equipment *pb.DB_Equipment, err error) {
|
||||||
var (
|
var (
|
||||||
mattr []*cfg.Game_equipAttrlibraryData
|
mattr []*cfg.Game_equipAttrlibraryData
|
||||||
sattr []*cfg.Game_equipAttrlibraryData
|
sattr []*cfg.Game_equipAttrlibraryData
|
||||||
@ -184,7 +184,7 @@ func (this *ModelEquipmentComp) newEquipment(uid string, conf *cfg.Game_equipDat
|
|||||||
}
|
}
|
||||||
|
|
||||||
//升级武器
|
//升级武器
|
||||||
func (this *ModelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) {
|
func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equip *cfg.Game_equipData, intensify *cfg.Game_equipIntensifyData) (err error) {
|
||||||
equipment.Lv++
|
equipment.Lv++
|
||||||
equipment.MainEntry.Lv++
|
equipment.MainEntry.Lv++
|
||||||
equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0)
|
equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0)
|
||||||
|
@ -23,9 +23,9 @@ func NewModule() core.IModule {
|
|||||||
type Equipment struct {
|
type Equipment struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
service core.IService
|
service core.IService
|
||||||
api *ApiComp
|
api *apiComp
|
||||||
configure *ConfigureComp
|
configure *configureComp
|
||||||
modelequipment *ModelEquipmentComp
|
modelEquipment *modelEquipmentComp
|
||||||
hero comm.IHero
|
hero comm.IHero
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,16 +56,16 @@ func (this *Equipment) Start() (err error) {
|
|||||||
//装备组件
|
//装备组件
|
||||||
func (this *Equipment) OnInstallComp() {
|
func (this *Equipment) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api = this.RegisterComp(new(ApiComp)).(*ApiComp)
|
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
this.modelequipment = this.RegisterComp(new(ModelEquipmentComp)).(*ModelEquipmentComp)
|
this.modelEquipment = this.RegisterComp(new(modelEquipmentComp)).(*modelEquipmentComp)
|
||||||
this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp)
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
||||||
//查询武器信息
|
//查询武器信息
|
||||||
func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
||||||
var err error
|
var err error
|
||||||
if equipment, err = this.modelequipment.QueryUserEquipmentsById(uid, Id); err != nil {
|
if equipment, err = this.modelEquipment.QueryUserEquipmentsById(uid, Id); err != nil {
|
||||||
if err == redis.Nil {
|
if err == redis.Nil {
|
||||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||||
} else {
|
} else {
|
||||||
@ -77,14 +77,14 @@ func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string,
|
|||||||
|
|
||||||
//查询卡片数量
|
//查询卡片数量
|
||||||
func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) {
|
func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) {
|
||||||
amount = this.modelequipment.QueryEquipmentAmount(uid, equipmentId)
|
amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加武器
|
//添加武器
|
||||||
func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) {
|
func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) {
|
||||||
var err error
|
var err error
|
||||||
if err = this.modelequipment.AddEquipments(uid, cIds); err != nil {
|
if err = this.modelEquipment.AddEquipments(uid, cIds); err != nil {
|
||||||
log.Errorf("err%v", err)
|
log.Errorf("err%v", err)
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,21 @@ import (
|
|||||||
/*
|
/*
|
||||||
装备模块 API
|
装备模块 API
|
||||||
*/
|
*/
|
||||||
type Api_Comp struct {
|
type apiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
module *Forum
|
module *Forum
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MComp_GateComp.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.module = module.(*Forum)
|
this.module = module.(*Forum)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MComp_GateComp.Start()
|
err = this.MCompGate.Start()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
///背包配置管理组件
|
///背包配置管理组件
|
||||||
type Configure_Comp struct {
|
type configureComp struct {
|
||||||
modules.MComp_Configure
|
modules.MCompConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.ModuleCompBase.Init(service, module, comp, options)
|
this.ModuleCompBase.Init(service, module, comp, options)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -9,14 +9,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
///论坛 数据组件
|
///论坛 数据组件
|
||||||
type Model_Forum_Comp struct {
|
type modelForumComp struct {
|
||||||
modules.Model_Comp
|
modules.MCompModel
|
||||||
module *Forum
|
module *Forum
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *Model_Forum_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
func (this *modelForumComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||||
this.Model_Comp.Init(service, module, comp, opt)
|
this.MCompModel.Init(service, module, comp, opt)
|
||||||
this.module = module.(*Forum)
|
this.module = module.(*Forum)
|
||||||
this.TableName = "forum"
|
this.TableName = "forum"
|
||||||
//创建uid索引
|
//创建uid索引
|
||||||
|
@ -18,9 +18,9 @@ func NewModule() core.IModule {
|
|||||||
|
|
||||||
type Forum struct {
|
type Forum struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
api_comp *Api_Comp
|
api_comp *apiComp
|
||||||
configure_comp *Configure_Comp
|
configure_comp *configureComp
|
||||||
model_forum_comp *Model_Forum_Comp
|
model_forum_comp *modelForumComp
|
||||||
}
|
}
|
||||||
|
|
||||||
//模块名
|
//模块名
|
||||||
@ -37,7 +37,7 @@ func (this *Forum) Init(service core.IService, module core.IModule, options core
|
|||||||
//装备组件
|
//装备组件
|
||||||
func (this *Forum) OnInstallComp() {
|
func (this *Forum) OnInstallComp() {
|
||||||
this.ModuleBase.OnInstallComp()
|
this.ModuleBase.OnInstallComp()
|
||||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||||
this.model_forum_comp = this.RegisterComp(new(Model_Forum_Comp)).(*Model_Forum_Comp)
|
this.model_forum_comp = this.RegisterComp(new(modelForumComp)).(*modelForumComp)
|
||||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
this.configure_comp = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ApiComp struct {
|
type ApiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MCompGate
|
||||||
module *Friend
|
module *Friend
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MComp_GateComp.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.module = module.(*Friend)
|
this.module = module.(*Friend)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ModelFriend struct {
|
type ModelFriend struct {
|
||||||
modules.Model_Comp
|
modules.MCompModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.Model_Comp.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.TableName = "friend"
|
this.TableName = "friend"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error {
|
|||||||
UserSessionId: this.sessionId,
|
UserSessionId: this.sessionId,
|
||||||
UserId: this.uId,
|
UserId: this.uId,
|
||||||
GatewayServiceId: this.gateway.Service().GetId(),
|
GatewayServiceId: this.gateway.Service().GetId(),
|
||||||
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
|
MainType: msg.MainType,
|
||||||
|
SubType: msg.SubType,
|
||||||
Message: msg.Data,
|
Message: msg.Data,
|
||||||
}, reply); err != nil {
|
}, reply); err != nil {
|
||||||
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||||
|
@ -53,7 +53,7 @@ func (this *AgentMgrComp) Bind(ctx context.Context, args *pb.AgentBuildReq, repl
|
|||||||
a.(IAgent).Bind(args.UserId, args.WorkerId)
|
a.(IAgent).Bind(args.UserId, args.WorkerId)
|
||||||
} else {
|
} else {
|
||||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq,
|
|||||||
a.(IAgent).UnBind()
|
a.(IAgent).UnBind()
|
||||||
} else {
|
} else {
|
||||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSend
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ func (this *AgentMgrComp) CloseAgent(ctx context.Context, args *pb.AgentCloseeRe
|
|||||||
a.(IAgent).Close()
|
a.(IAgent).Close()
|
||||||
} else {
|
} else {
|
||||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
moduleHero *Hero
|
moduleHero *Hero
|
||||||
user comm.IUser
|
user comm.IUser
|
||||||
@ -21,14 +21,14 @@ const ( //消息回复的头名称
|
|||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MComp_GateComp.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.moduleHero = module.(*Hero)
|
this.moduleHero = module.(*Hero)
|
||||||
this.service = service
|
this.service = service
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MComp_GateComp.Start()
|
err = this.MCompGate.Start()
|
||||||
|
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@ const (
|
|||||||
|
|
||||||
///配置管理组件
|
///配置管理组件
|
||||||
type configureComp struct {
|
type configureComp struct {
|
||||||
modules.MComp_Configure
|
modules.MCompConfigure
|
||||||
}
|
}
|
||||||
|
|
||||||
//组件初始化接口
|
//组件初始化接口
|
||||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
|
|
||||||
err = this.MComp_Configure.Init(service, module, comp, options)
|
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||||
new_hero: cfg.NewGame_newHero,
|
new_hero: cfg.NewGame_newHero,
|
||||||
hero_stargrow: cfg.NewGame_heroStargrow,
|
hero_stargrow: cfg.NewGame_heroStargrow,
|
||||||
|
@ -15,12 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ModelHero struct {
|
type ModelHero struct {
|
||||||
modules.Model_Comp
|
modules.MCompModel
|
||||||
moduleHero *Hero
|
moduleHero *Hero
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelHero) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelHero) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.Model_Comp.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.moduleHero = module.(*Hero)
|
this.moduleHero = module.(*Hero)
|
||||||
this.TableName = "hero"
|
this.TableName = "hero"
|
||||||
return
|
return
|
||||||
|
@ -76,7 +76,7 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
func Test_Modules(t *testing.T) {
|
func Test_Modules(t *testing.T) {
|
||||||
data, _ := ptypes.MarshalAny(&pb.Items_Getlist_Req{})
|
data, _ := ptypes.MarshalAny(&pb.Items_Getlist_Req{})
|
||||||
s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{Method: "pack.getlist", Message: data}, &pb.RPCMessageReply{})
|
s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{MainType: "pack", SubType: "getlist", Message: data}, &pb.RPCMessageReply{})
|
||||||
// items, err := module.db_comp.Pack_QueryUserPack("liwei1dao")
|
// items, err := module.db_comp.Pack_QueryUserPack("liwei1dao")
|
||||||
// log.Debugf("item:%v err:%v", items, err)
|
// log.Debugf("item:%v err:%v", items, err)
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,14 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MCompGate
|
||||||
service core.IService
|
service core.IService
|
||||||
module *Mail
|
module *Mail
|
||||||
items comm.IItems
|
items comm.IItems
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MComp_GateComp.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.service = service
|
this.service = service
|
||||||
this.module = module.(*Mail)
|
this.module = module.(*Mail)
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ func (this *apiComp) Init(service core.IService, module core.IModule, comp core.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MComp_GateComp.Start()
|
err = this.MCompGate.Start()
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
|
|
||||||
if module, err = this.service.GetModule(comm.SM_ItemsModule); err != nil {
|
if module, err = this.service.GetModule(comm.SM_ItemsModule); err != nil {
|
||||||
|
@ -57,7 +57,7 @@ func (this *Mail) CreateNewMail(uId string) {
|
|||||||
}
|
}
|
||||||
// 通知玩家
|
// 通知玩家
|
||||||
var _cache = &pb.Cache_UserData{}
|
var _cache = &pb.Cache_UserData{}
|
||||||
err = this.modelMail.Model_Comp.Get(uId, _cache)
|
err = this.modelMail.MCompModel.Get(uId, _cache)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -158,11 +158,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
|||||||
} else if v.A == comm.CardType { //卡片资源
|
} else if v.A == comm.CardType { //卡片资源
|
||||||
resID, _ = strconv.Atoi(v.T)
|
resID, _ = strconv.Atoi(v.T)
|
||||||
hero.ChangeCard(uid, int32(resID), -1*v.N)
|
hero.ChangeCard(uid, int32(resID), -1*v.N)
|
||||||
} else if v.A == comm.EquipmentType {
|
|
||||||
resID, _ = strconv.Atoi(v.T)
|
|
||||||
equipment.AddNewEquipments(source, uid, resID, -1*v.N)
|
|
||||||
}
|
}
|
||||||
//不存在消耗武器的情况
|
|
||||||
// } else if v.A == comm.EquipmentType {
|
// } else if v.A == comm.EquipmentType {
|
||||||
// resID, _ = strconv.Atoi(v.T)
|
// resID, _ = strconv.Atoi(v.T)
|
||||||
// equipment.AddNewEquipments(source, uid, resID, -1*v.N)
|
// equipment.AddNewEquipments(source, uid, resID, -1*v.N)
|
||||||
|
@ -15,21 +15,21 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type apiComp struct {
|
type apiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MCompGate
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
module *User
|
module *User
|
||||||
hero comm.IHero
|
hero comm.IHero
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
this.MComp_GateComp.Init(service, module, comp, options)
|
this.MCompGate.Init(service, module, comp, options)
|
||||||
this.service = service.(base.IRPCXService)
|
this.service = service.(base.IRPCXService)
|
||||||
this.module = module.(*User)
|
this.module = module.(*User)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MComp_GateComp.Start()
|
err = this.MCompGate.Start()
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
|
|
||||||
//get module hero
|
//get module hero
|
||||||
|
@ -6,11 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ModelSession struct {
|
type ModelSession struct {
|
||||||
modules.Model_Comp
|
modules.MCompModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelSession) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.Model_Comp.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.TableName = "session"
|
this.TableName = "session"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ const ( //Redis
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ModelUser struct {
|
type ModelUser struct {
|
||||||
modules.Model_Comp
|
modules.MCompModel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
func (this *ModelUser) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||||
err = this.Model_Comp.Init(service, module, comp, options)
|
err = this.MCompModel.Init(service, module, comp, options)
|
||||||
this.TableName = "user"
|
this.TableName = "user"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
177
pb/comm.pb.go
177
pb/comm.pb.go
@ -160,8 +160,9 @@ type AgentMessage struct {
|
|||||||
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId"`
|
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId"`
|
||||||
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId"`
|
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId"`
|
||||||
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"`
|
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"`
|
||||||
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method"`
|
MainType string `protobuf:"bytes,5,opt,name=MainType,proto3" json:"MainType"`
|
||||||
Message *anypb.Any `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message"`
|
SubType string `protobuf:"bytes,6,opt,name=SubType,proto3" json:"SubType"`
|
||||||
|
Message *anypb.Any `protobuf:"bytes,7,opt,name=Message,proto3" json:"Message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentMessage) Reset() {
|
func (x *AgentMessage) Reset() {
|
||||||
@ -224,9 +225,16 @@ func (x *AgentMessage) GetGatewayServiceId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentMessage) GetMethod() string {
|
func (x *AgentMessage) GetMainType() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Method
|
return x.MainType
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *AgentMessage) GetSubType() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.SubType
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -244,9 +252,10 @@ type RPCMessageReply struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"`
|
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"`
|
||||||
Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message"`
|
ErrorMessage string `protobuf:"bytes,2,opt,name=ErrorMessage,proto3" json:"ErrorMessage"`
|
||||||
Data string `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data"`
|
ErrorData string `protobuf:"bytes,3,opt,name=ErrorData,proto3" json:"ErrorData"`
|
||||||
|
Reply *UserMessage `protobuf:"bytes,4,opt,name=Reply,proto3" json:"Reply"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RPCMessageReply) Reset() {
|
func (x *RPCMessageReply) Reset() {
|
||||||
@ -288,20 +297,27 @@ func (x *RPCMessageReply) GetCode() ErrorCode {
|
|||||||
return ErrorCode_Success
|
return ErrorCode_Success
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RPCMessageReply) GetMessage() string {
|
func (x *RPCMessageReply) GetErrorMessage() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Message
|
return x.ErrorMessage
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *RPCMessageReply) GetData() string {
|
func (x *RPCMessageReply) GetErrorData() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.ErrorData
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *RPCMessageReply) GetReply() *UserMessage {
|
||||||
|
if x != nil {
|
||||||
|
return x.Reply
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
//用户代理绑定Uid请求
|
//用户代理绑定Uid请求
|
||||||
type AgentBuildReq struct {
|
type AgentBuildReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -732,7 +748,7 @@ var file_comm_proto_rawDesc = []byte{
|
|||||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f,
|
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f,
|
||||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e,
|
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e,
|
||||||
0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x04,
|
0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x04,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x65, 0x63, 0x22, 0xee, 0x01, 0x0a, 0x0c, 0x41, 0x67,
|
||||||
0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70,
|
0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
||||||
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
@ -741,66 +757,72 @@ var file_comm_proto_rawDesc = []byte{
|
|||||||
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65,
|
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65,
|
||||||
0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01,
|
0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01,
|
||||||
0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69,
|
0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69,
|
||||||
0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05,
|
0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07,
|
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65,
|
||||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
|
0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||||
|
0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x2e, 0x0a, 0x07, 0x4d, 0x65,
|
||||||
|
0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f,
|
||||||
|
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e,
|
||||||
|
0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x97, 0x01, 0x0a, 0x0f, 0x52,
|
||||||
|
0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e,
|
||||||
|
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
|
||||||
|
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x22,
|
||||||
|
0x0a, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||||
|
0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18,
|
||||||
|
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61,
|
||||||
|
0x12, 0x22, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||||
|
0x0c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x52,
|
||||||
|
0x65, 0x70, 0x6c, 0x79, 0x22, 0x69, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69,
|
||||||
|
0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
|
0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73,
|
||||||
|
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55,
|
||||||
|
0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65,
|
||||||
|
0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18,
|
||||||
|
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22,
|
||||||
|
0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52,
|
||||||
|
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||||
|
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
|
||||||
|
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65,
|
||||||
|
0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71,
|
||||||
|
0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
|
||||||
|
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
|
0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79,
|
||||||
|
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79,
|
||||||
|
0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04,
|
||||||
|
0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f,
|
||||||
|
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79,
|
||||||
|
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68,
|
||||||
|
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73,
|
||||||
|
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03,
|
||||||
|
0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
|
||||||
|
0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02,
|
||||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18,
|
||||||
|
0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
|
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61,
|
||||||
|
0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||||
|
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61,
|
||||||
|
0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d,
|
||||||
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69,
|
||||||
|
0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69,
|
||||||
|
0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65,
|
||||||
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||||
|
0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
|
||||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
|
||||||
0x41, 0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 0x0a, 0x0f,
|
0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65,
|
||||||
0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12,
|
0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55,
|
||||||
0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e,
|
|
||||||
0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
|
||||||
0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
|
||||||
0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74,
|
|
||||||
0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x69, 0x0a,
|
|
||||||
0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24,
|
|
||||||
0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18,
|
|
||||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
|
|
||||||
0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02,
|
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
|
|
||||||
0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
|
||||||
0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e,
|
|
||||||
0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55,
|
|
||||||
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
|
0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
|
||||||
0x64, 0x22, 0x9b, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d,
|
0x64, 0x22, 0x2c, 0x0a, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x43,
|
||||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
|
0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
||||||
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a,
|
||||||
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
|
0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65,
|
||||||
0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a,
|
||||||
0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53,
|
0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12,
|
||||||
0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75,
|
0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72,
|
||||||
0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
|
0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
|
0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22,
|
|
||||||
0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
|
||||||
0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
|
|
||||||
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65,
|
|
||||||
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d,
|
|
||||||
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d,
|
|
||||||
0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
|
|
||||||
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70,
|
|
||||||
0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
|
||||||
0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
|
||||||
0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42,
|
|
||||||
0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52,
|
|
||||||
0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01,
|
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18,
|
|
||||||
0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
|
||||||
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61,
|
|
||||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61,
|
|
||||||
0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65,
|
|
||||||
0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73,
|
|
||||||
0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65,
|
|
||||||
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x12, 0x4e, 0x6f,
|
|
||||||
0x74, 0x69, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x52, 0x65, 0x71,
|
|
||||||
0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
|
||||||
0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f,
|
|
||||||
0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06,
|
|
||||||
0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12,
|
|
||||||
0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65,
|
|
||||||
0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a,
|
|
||||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -836,14 +858,15 @@ var file_comm_proto_depIdxs = []int32{
|
|||||||
11, // 0: UserMessage.data:type_name -> google.protobuf.Any
|
11, // 0: UserMessage.data:type_name -> google.protobuf.Any
|
||||||
11, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
|
11, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
|
||||||
12, // 2: RPCMessageReply.Code:type_name -> ErrorCode
|
12, // 2: RPCMessageReply.Code:type_name -> ErrorCode
|
||||||
11, // 3: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
1, // 3: RPCMessageReply.Reply:type_name -> UserMessage
|
||||||
11, // 4: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
11, // 4: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
||||||
11, // 5: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
|
11, // 5: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
||||||
6, // [6:6] is the sub-list for method output_type
|
11, // 6: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
|
||||||
6, // [6:6] is the sub-list for method input_type
|
7, // [7:7] is the sub-list for method output_type
|
||||||
6, // [6:6] is the sub-list for extension type_name
|
7, // [7:7] is the sub-list for method input_type
|
||||||
6, // [6:6] is the sub-list for extension extendee
|
7, // [7:7] is the sub-list for extension type_name
|
||||||
0, // [0:6] is the sub-list for field type_name
|
7, // [7:7] is the sub-list for extension extendee
|
||||||
|
0, // [0:7] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_comm_proto_init() }
|
func init() { file_comm_proto_init() }
|
||||||
|
@ -18,8 +18,9 @@ message AgentMessage {
|
|||||||
string UserSessionId = 2;
|
string UserSessionId = 2;
|
||||||
string UserId = 3;
|
string UserId = 3;
|
||||||
string GatewayServiceId = 4;
|
string GatewayServiceId = 4;
|
||||||
string Method = 5;
|
string MainType = 5;
|
||||||
google.protobuf.Any Message = 6;
|
string SubType = 6;
|
||||||
|
google.protobuf.Any Message = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC 服务固定回复结构
|
// RPC 服务固定回复结构
|
||||||
|
@ -33,9 +33,11 @@ func NewGateRouteComp() comm.ISC_GateRouteComp {
|
|||||||
|
|
||||||
//用户协议处理函数注册的反射对象
|
//用户协议处理函数注册的反射对象
|
||||||
type msghandle struct {
|
type msghandle struct {
|
||||||
rcvr reflect.Value
|
rcvr reflect.Value
|
||||||
msgType reflect.Type
|
msgType reflect.Type //消息请求类型
|
||||||
fn reflect.Method
|
replyType reflect.Type //消息回应类型
|
||||||
|
check reflect.Method //校验函数
|
||||||
|
handle reflect.Method //处理函数
|
||||||
}
|
}
|
||||||
|
|
||||||
//服务网关组件
|
//服务网关组件
|
||||||
@ -43,7 +45,6 @@ type SCompGateRoute struct {
|
|||||||
cbase.ServiceCompBase
|
cbase.ServiceCompBase
|
||||||
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
||||||
mrlock sync.RWMutex //msghandles 对象的锁
|
mrlock sync.RWMutex //msghandles 对象的锁
|
||||||
msgcheck map[string]*msghandle //处理函数的校验接口
|
|
||||||
msghandles map[string]*msghandle //处理函数的管理对象
|
msghandles map[string]*msghandle //处理函数的管理对象
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,6 @@ func (this *SCompGateRoute) GetName() core.S_Comps {
|
|||||||
func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, options core.ICompOptions) (err error) {
|
func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, options core.ICompOptions) (err error) {
|
||||||
err = this.ServiceCompBase.Init(service, comp, options)
|
err = this.ServiceCompBase.Init(service, comp, options)
|
||||||
this.service = service.(base.IRPCXService)
|
this.service = service.(base.IRPCXService)
|
||||||
this.msgcheck = make(map[string]*msghandle)
|
|
||||||
this.msghandles = make(map[string]*msghandle)
|
this.msghandles = make(map[string]*msghandle)
|
||||||
return err
|
return err
|
||||||
} //
|
} //
|
||||||
@ -66,25 +66,11 @@ 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_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知
|
||||||
err = this.ServiceCompBase.Start()
|
err = this.ServiceCompBase.Start()
|
||||||
event.RegisterGO(core.Event_ServiceStartEnd, func() {
|
|
||||||
for k, v := range this.msghandles {
|
|
||||||
if v1, ok := this.msgcheck[k]; !ok {
|
|
||||||
log.Panicf("注册用户消息处理函数:%s 没有实现参数校验接口", k)
|
|
||||||
return
|
|
||||||
} else if v.msgType != v1.msgType {
|
|
||||||
log.Panicf("注册用户消息处理函数:%s 实现参数校验接口不一致 请检查代码!", k)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
event.RegisterGO(core.Event_FindNewService, func() {
|
|
||||||
log.Debugf("find new service")
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//业务模块注册用户消息处理路由
|
//业务模块注册用户消息处理路由
|
||||||
func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) {
|
func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, replyType reflect.Type, check, handele reflect.Method) {
|
||||||
log.Debugf("注册用户路由【%s】", methodName)
|
log.Debugf("注册用户路由【%s】", methodName)
|
||||||
this.mrlock.RLock()
|
this.mrlock.RLock()
|
||||||
_, ok := this.msghandles[methodName]
|
_, ok := this.msghandles[methodName]
|
||||||
@ -95,28 +81,11 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value,
|
|||||||
}
|
}
|
||||||
this.mrlock.Lock()
|
this.mrlock.Lock()
|
||||||
this.msghandles[methodName] = &msghandle{
|
this.msghandles[methodName] = &msghandle{
|
||||||
rcvr: comp,
|
rcvr: comp,
|
||||||
msgType: msg,
|
msgType: msg,
|
||||||
fn: fn,
|
replyType: replyType,
|
||||||
}
|
check: check,
|
||||||
this.mrlock.Unlock()
|
handle: handele,
|
||||||
}
|
|
||||||
|
|
||||||
//业务模块注册用户消息处理路由
|
|
||||||
func (this *SCompGateRoute) RegisterRouteCheck(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) {
|
|
||||||
log.Debugf("注册用户路由校验[%s]", methodName)
|
|
||||||
this.mrlock.RLock()
|
|
||||||
_, ok := this.msgcheck[methodName]
|
|
||||||
this.mrlock.RUnlock()
|
|
||||||
if ok {
|
|
||||||
log.Errorf("重复 注册用户路由校验[%s]", methodName)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.mrlock.Lock()
|
|
||||||
this.msgcheck[methodName] = &msghandle{
|
|
||||||
rcvr: comp,
|
|
||||||
msgType: msg,
|
|
||||||
fn: fn,
|
|
||||||
}
|
}
|
||||||
this.mrlock.Unlock()
|
this.mrlock.Unlock()
|
||||||
}
|
}
|
||||||
@ -128,15 +97,15 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
|||||||
buf := make([]byte, 1024)
|
buf := make([]byte, 1024)
|
||||||
l := runtime.Stack(buf, false)
|
l := runtime.Stack(buf, false)
|
||||||
reply.Code = pb.ErrorCode_Exception
|
reply.Code = pb.ErrorCode_Exception
|
||||||
reply.Message = fmt.Sprintf("%v: %s", r, buf[:l])
|
reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||||
log.Errorf("HandleUserMsg:%s err:%s", args.Method, reply.Message)
|
log.Errorf("HandleUserMsg:[%s-%s] err:%s", args.MainType, args.SubType, reply.ErrorMessage)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.Debugf("SCompGateRoute ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method)
|
log.Debugf("SCompGateRoute ReceiveMsg agent:%s uId:%s MessageDistribution:[%s-%s]", args.UserSessionId, args.UserId, args.MainType, args.SubType)
|
||||||
|
method := fmt.Sprintf("%s.%s", args.MainType, args.SubType)
|
||||||
//获取用户消息处理函数
|
//获取用户消息处理函数
|
||||||
this.mrlock.RLock()
|
this.mrlock.RLock()
|
||||||
msghandle, ok := this.msghandles[args.Method]
|
msghandle, ok := this.msghandles[method]
|
||||||
msgcheck := this.msgcheck[args.Method]
|
|
||||||
this.mrlock.RUnlock()
|
this.mrlock.RUnlock()
|
||||||
if ok {
|
if ok {
|
||||||
//封装用户会话
|
//封装用户会话
|
||||||
@ -144,24 +113,27 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
|||||||
//序列化用户消息对象
|
//序列化用户消息对象
|
||||||
msg := reflect.New(msghandle.msgType.Elem()).Interface()
|
msg := reflect.New(msghandle.msgType.Elem()).Interface()
|
||||||
if err := ptypes.UnmarshalAny(args.Message, msg.(proto.Message)); err != nil {
|
if err := ptypes.UnmarshalAny(args.Message, msg.(proto.Message)); err != nil {
|
||||||
log.Errorf("UserMessage:%s Unmarshal err:%v", args.Method, err)
|
log.Errorf("UserMessage:%s Unmarshal err:%v", method, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//序列化用户消息对象
|
||||||
|
replymsg := reflect.New(msghandle.replyType.Elem()).Interface()
|
||||||
|
|
||||||
//调用校验接口
|
//调用校验接口
|
||||||
checkreturn := msgcheck.fn.Func.Call([]reflect.Value{msgcheck.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)})
|
checkreturn := msghandle.check.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)})
|
||||||
//读取校验结果 有错误直接返回错误码给用户
|
//读取校验结果 有错误直接返回错误码给用户
|
||||||
code := checkreturn[1].Interface().(comm.ErrorCode)
|
code := checkreturn[1].Interface().(comm.ErrorCode)
|
||||||
if code.Code != pb.ErrorCode_Success {
|
if code.Code != pb.ErrorCode_Success {
|
||||||
log.Errorf("HandleUserMsg:%s msg:%v code:%d", args.Method, msg, code)
|
log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, code)
|
||||||
reply.Code = code.Code
|
reply.Code = code.Code
|
||||||
reply.Message = pb.GetErrorCodeMsg(code.Code)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(code.Code)
|
||||||
if code.Data != nil { //处理错误附加数据 采用json 序列化为string
|
if code.Data != nil { //处理错误附加数据 采用json 序列化为string
|
||||||
if d, err := jsoniter.Marshal(code.Data); err != nil {
|
if d, err := jsoniter.Marshal(code.Data); err != nil {
|
||||||
log.Errorf("HandleUserMsg:%s msg:%v code:%d err:%v", args.Method, msg, code, err)
|
log.Errorf("HandleUserMsg:%s msg:%v code:%d err:%v", method, msg, code, err)
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
reply.Data = codec.BytesToString(d)
|
reply.ErrorData = codec.BytesToString(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -169,12 +141,12 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
|||||||
//校验结果成功 处理临时数据转移
|
//校验结果成功 处理临时数据转移
|
||||||
result := checkreturn[0].Interface().(map[string]interface{})
|
result := checkreturn[0].Interface().(map[string]interface{})
|
||||||
//调用用户处理函数
|
//调用用户处理函数
|
||||||
handlereturn := msghandle.fn.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg)})
|
handlereturn := msghandle.handle.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(result), reflect.ValueOf(msg), reflect.ValueOf(replymsg)})
|
||||||
errcode := pb.ErrorCode(handlereturn[0].Int())
|
errcode := pb.ErrorCode(handlereturn[0].Int())
|
||||||
if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息
|
if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息
|
||||||
log.Errorf("HandleUserMsg:%s msg:%v code:%d", args.Method, msg, code)
|
log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, code)
|
||||||
reply.Code = errcode
|
reply.Code = errcode
|
||||||
reply.Message = pb.GetErrorCodeMsg(errcode)
|
reply.ErrorMessage = pb.GetErrorCodeMsg(errcode)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
} else { //未找到消息处理函数
|
} else { //未找到消息处理函数
|
||||||
|
Loading…
Reference in New Issue
Block a user