上传协议修改代码
This commit is contained in:
parent
ce2f052465
commit
6098f3edda
@ -16,8 +16,7 @@ import (
|
||||
type ISC_GateRouteComp interface {
|
||||
core.IServiceComp
|
||||
ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error
|
||||
RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method)
|
||||
RegisterRouteCheck(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)
|
||||
}
|
||||
|
||||
//游戏类资源类型
|
||||
@ -35,8 +34,6 @@ type Autogenerated struct {
|
||||
D []interface{}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const (
|
||||
HeroStarLvRatio int32 = 10 // 卡牌等级上限系数(星级*10)
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"log"
|
||||
"reflect"
|
||||
"strings"
|
||||
"unicode"
|
||||
@ -56,27 +57,27 @@ func (this *MCompGate) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.scomp = comp.(comm.ISC_GateRouteComp)
|
||||
this.suitableMethods(reflect.TypeOf(this.comp))
|
||||
this.suitableMethods()
|
||||
return
|
||||
}
|
||||
|
||||
//反射注册相关接口道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++ {
|
||||
method := typ.Method(m)
|
||||
this.reflectionRouteHandle(method)
|
||||
this.reflectionRouteCheck(method)
|
||||
this.reflectionRouteHandle(typ, method)
|
||||
}
|
||||
}
|
||||
|
||||
//反射注册路由处理函数
|
||||
func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
||||
func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Method) {
|
||||
mtype := method.Type
|
||||
mname := method.Name
|
||||
if method.PkgPath != "" {
|
||||
return
|
||||
}
|
||||
if mtype.NumIn() != 4 {
|
||||
if mtype.NumIn() != 5 {
|
||||
return
|
||||
}
|
||||
ctxType := mtype.In(1)
|
||||
@ -87,13 +88,21 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
||||
if !argType.Implements(typeOfMapStringIntface) {
|
||||
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 {
|
||||
return
|
||||
}
|
||||
if !this.isExportedOrBuiltinType(replyType) {
|
||||
return
|
||||
}
|
||||
|
||||
if mtype.NumOut() != 1 {
|
||||
return
|
||||
}
|
||||
@ -101,45 +110,51 @@ func (this *MCompGate) reflectionRouteHandle(method reflect.Method) {
|
||||
if returnCodeType != typeOfErrorCode {
|
||||
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
|
||||
mname := strings.Split(method.Name, "_")
|
||||
if len(mname) != 2 || mname[1] != "Check" {
|
||||
return
|
||||
}
|
||||
|
||||
if method.PkgPath != "" {
|
||||
return
|
||||
return fmt.Errorf("method.PkgPath:%v", method.PkgPath)
|
||||
}
|
||||
if mtype.NumIn() != 3 {
|
||||
return
|
||||
return fmt.Errorf("mtype.NumIn():%v", mtype.NumIn())
|
||||
}
|
||||
ctxType := mtype.In(1)
|
||||
if !ctxType.Implements(typeOfSession) {
|
||||
return
|
||||
return fmt.Errorf("ctxType:%T", ctxType)
|
||||
}
|
||||
replyType := mtype.In(2)
|
||||
if replyType.Kind() != reflect.Ptr {
|
||||
return
|
||||
}
|
||||
if !this.isExportedOrBuiltinType(replyType) {
|
||||
return
|
||||
if replyType != msgtype {
|
||||
return fmt.Errorf("replyType:%T", replyType)
|
||||
}
|
||||
if mtype.NumOut() != 2 {
|
||||
return
|
||||
return fmt.Errorf("mtype.NumOut():%d", mtype.NumOut())
|
||||
}
|
||||
returnMapType := mtype.Out(0)
|
||||
if !returnMapType.Implements(typeOfMapStringIntface) {
|
||||
return
|
||||
return fmt.Errorf("returnMapType:%T", returnMapType)
|
||||
}
|
||||
returnCodeType := mtype.Out(1)
|
||||
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 {
|
||||
|
@ -134,7 +134,7 @@ func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs .
|
||||
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -9,21 +9,21 @@ import (
|
||||
/*
|
||||
装备模块 API
|
||||
*/
|
||||
type ApiComp struct {
|
||||
type apiComp struct {
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
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.module = module.(*Equipment)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ApiComp) Start() (err error) {
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MCompGate.Start()
|
||||
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 (
|
||||
err error
|
||||
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))
|
||||
for i, v := range req.EquipmentId {
|
||||
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)
|
||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
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 (
|
||||
err error
|
||||
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 {
|
||||
if v != "" {
|
||||
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)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
@ -73,7 +73,7 @@ func (this *ApiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
||||
equipments[i].HeroId = hero.Id
|
||||
updatequipment = append(updatequipment, equipment, equipments[i])
|
||||
} 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)
|
||||
code = pb.ErrorCode_SystemError
|
||||
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 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)
|
||||
code = pb.ErrorCode_SystemError
|
||||
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
|
||||
}
|
||||
|
||||
///获取用户装备列表
|
||||
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 (
|
||||
err error
|
||||
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})
|
||||
// }
|
||||
// }()
|
||||
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)
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
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 (
|
||||
err error
|
||||
conf *cfg.Game_equipData
|
||||
@ -24,7 +24,7 @@ func (this *ApiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
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)
|
||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
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 (
|
||||
err error
|
||||
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 {
|
||||
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,
|
||||
"heroId": "",
|
||||
}); err != nil {
|
||||
@ -97,24 +97,24 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
||||
equipment.Id = primitive.NewObjectID().Hex()
|
||||
equipment.IsInitialState = false
|
||||
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
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
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)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
} else {
|
||||
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
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
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,
|
||||
"mainEntry": equipment.MainEntry,
|
||||
"adverbEntry": equipment.AdverbEntry,
|
||||
@ -136,7 +136,7 @@ func (this *ApiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
||||
for i, v := range hero.EquipID {
|
||||
if v != "" {
|
||||
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)
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
|
@ -17,12 +17,12 @@ const (
|
||||
)
|
||||
|
||||
///背包配置管理组件
|
||||
type ConfigureComp struct {
|
||||
type configureComp struct {
|
||||
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.LoadConfigure(game_equip, cfg.NewGame_equip)
|
||||
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 (
|
||||
v interface{}
|
||||
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 (
|
||||
v interface{}
|
||||
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 (
|
||||
v interface{}
|
||||
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 (
|
||||
v interface{}
|
||||
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 (
|
||||
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 (
|
||||
v interface{}
|
||||
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 (
|
||||
v interface{}
|
||||
ok bool
|
||||
|
@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
///装备 数据组件
|
||||
type ModelEquipmentComp struct {
|
||||
type modelEquipmentComp struct {
|
||||
modules.MCompModel
|
||||
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.module = module.(*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{}
|
||||
err = this.GetListObj(uId, id, equipment)
|
||||
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)
|
||||
err = this.GetList(uId, &equipments)
|
||||
return
|
||||
}
|
||||
|
||||
///查询目标卡片数量
|
||||
func (this *ModelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) {
|
||||
func (this *modelEquipmentComp) QueryEquipmentAmount(uid string, equipmentId int32) (amount uint32) {
|
||||
var (
|
||||
equipments []*pb.DB_Equipment
|
||||
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 (
|
||||
configure *cfg.Game_equip
|
||||
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 {
|
||||
if err = this.ChangeList(uid, v.Id, map[string]interface{}{
|
||||
"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 (
|
||||
mattr []*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.MainEntry.Lv++
|
||||
equipment.MainEntry.Value += equipment.MainEntry.Value * (intensify.Bonus / 1000.0)
|
||||
|
@ -23,9 +23,9 @@ func NewModule() core.IModule {
|
||||
type Equipment struct {
|
||||
modules.ModuleBase
|
||||
service core.IService
|
||||
api *ApiComp
|
||||
configure *ConfigureComp
|
||||
modelequipment *ModelEquipmentComp
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
modelEquipment *modelEquipmentComp
|
||||
hero comm.IHero
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ func (this *Equipment) Start() (err error) {
|
||||
//装备组件
|
||||
func (this *Equipment) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(ApiComp)).(*ApiComp)
|
||||
this.modelequipment = this.RegisterComp(new(ModelEquipmentComp)).(*ModelEquipmentComp)
|
||||
this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp)
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelEquipment = this.RegisterComp(new(modelEquipmentComp)).(*modelEquipmentComp)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
||||
//查询武器信息
|
||||
func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
||||
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 {
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
} 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) {
|
||||
amount = this.modelequipment.QueryEquipmentAmount(uid, equipmentId)
|
||||
amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId)
|
||||
return
|
||||
}
|
||||
|
||||
//添加武器
|
||||
func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) {
|
||||
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)
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
|
@ -9,21 +9,21 @@ import (
|
||||
/*
|
||||
装备模块 API
|
||||
*/
|
||||
type Api_Comp struct {
|
||||
modules.MComp_GateComp
|
||||
type apiComp struct {
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
module *Forum
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
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.module = module.(*Forum)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MCompGate.Start()
|
||||
return
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ const (
|
||||
)
|
||||
|
||||
///背包配置管理组件
|
||||
type Configure_Comp struct {
|
||||
modules.MComp_Configure
|
||||
type configureComp struct {
|
||||
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)
|
||||
|
||||
return
|
||||
|
@ -9,14 +9,14 @@ import (
|
||||
)
|
||||
|
||||
///论坛 数据组件
|
||||
type Model_Forum_Comp struct {
|
||||
modules.Model_Comp
|
||||
type modelForumComp struct {
|
||||
modules.MCompModel
|
||||
module *Forum
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Model_Forum_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||
this.Model_Comp.Init(service, module, comp, opt)
|
||||
func (this *modelForumComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
|
||||
this.MCompModel.Init(service, module, comp, opt)
|
||||
this.module = module.(*Forum)
|
||||
this.TableName = "forum"
|
||||
//创建uid索引
|
||||
|
@ -18,9 +18,9 @@ func NewModule() core.IModule {
|
||||
|
||||
type Forum struct {
|
||||
modules.ModuleBase
|
||||
api_comp *Api_Comp
|
||||
configure_comp *Configure_Comp
|
||||
model_forum_comp *Model_Forum_Comp
|
||||
api_comp *apiComp
|
||||
configure_comp *configureComp
|
||||
model_forum_comp *modelForumComp
|
||||
}
|
||||
|
||||
//模块名
|
||||
@ -37,7 +37,7 @@ func (this *Forum) Init(service core.IService, module core.IModule, options core
|
||||
//装备组件
|
||||
func (this *Forum) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||
this.model_forum_comp = this.RegisterComp(new(Model_Forum_Comp)).(*Model_Forum_Comp)
|
||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.model_forum_comp = this.RegisterComp(new(modelForumComp)).(*modelForumComp)
|
||||
this.configure_comp = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ const (
|
||||
)
|
||||
|
||||
type ApiComp struct {
|
||||
modules.MComp_GateComp
|
||||
modules.MCompGate
|
||||
module *Friend
|
||||
}
|
||||
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
@ -15,11 +15,11 @@ const (
|
||||
)
|
||||
|
||||
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) {
|
||||
err = this.Model_Comp.Init(service, module, comp, options)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = "friend"
|
||||
return
|
||||
}
|
||||
|
@ -224,7 +224,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error {
|
||||
UserSessionId: this.sessionId,
|
||||
UserId: this.uId,
|
||||
GatewayServiceId: this.gateway.Service().GetId(),
|
||||
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
|
||||
MainType: msg.MainType,
|
||||
SubType: msg.SubType,
|
||||
Message: msg.Data,
|
||||
}, reply); err != nil {
|
||||
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)
|
||||
} else {
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -64,7 +64,7 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq,
|
||||
a.(IAgent).UnBind()
|
||||
} else {
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -79,7 +79,7 @@ func (this *AgentMgrComp) SendMsgToAgent(ctx context.Context, args *pb.AgentSend
|
||||
})
|
||||
} else {
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -119,7 +119,7 @@ func (this *AgentMgrComp) CloseAgent(ctx context.Context, args *pb.AgentCloseeRe
|
||||
a.(IAgent).Close()
|
||||
} else {
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Message = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
modules.MComp_GateComp
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
moduleHero *Hero
|
||||
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) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
this.MCompGate.Init(service, module, comp, options)
|
||||
this.moduleHero = module.(*Hero)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
err = this.MCompGate.Start()
|
||||
|
||||
var module core.IModule
|
||||
|
||||
|
@ -19,13 +19,13 @@ const (
|
||||
|
||||
///配置管理组件
|
||||
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) {
|
||||
|
||||
err = this.MComp_Configure.Init(service, module, comp, options)
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
new_hero: cfg.NewGame_newHero,
|
||||
hero_stargrow: cfg.NewGame_heroStargrow,
|
||||
|
@ -15,12 +15,12 @@ import (
|
||||
)
|
||||
|
||||
type ModelHero struct {
|
||||
modules.Model_Comp
|
||||
modules.MCompModel
|
||||
moduleHero *Hero
|
||||
}
|
||||
|
||||
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.TableName = "hero"
|
||||
return
|
||||
|
@ -76,7 +76,7 @@ func TestMain(m *testing.M) {
|
||||
|
||||
func Test_Modules(t *testing.T) {
|
||||
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")
|
||||
// log.Debugf("item:%v err:%v", items, err)
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ const (
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
modules.MComp_GateComp
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
module *Mail
|
||||
items comm.IItems
|
||||
}
|
||||
|
||||
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.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) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
err = this.MCompGate.Start()
|
||||
var module core.IModule
|
||||
|
||||
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{}
|
||||
err = this.modelMail.Model_Comp.Get(uId, _cache)
|
||||
err = this.modelMail.MCompModel.Get(uId, _cache)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
@ -158,11 +158,7 @@ func (this *ModuleBase) CheckConsumeRes(uid string, res []*cfg.Game_atn) (code p
|
||||
} else if v.A == comm.CardType { //卡片资源
|
||||
resID, _ = strconv.Atoi(v.T)
|
||||
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 {
|
||||
// resID, _ = strconv.Atoi(v.T)
|
||||
// equipment.AddNewEquipments(source, uid, resID, -1*v.N)
|
||||
|
@ -15,21 +15,21 @@ const (
|
||||
)
|
||||
|
||||
type apiComp struct {
|
||||
modules.MComp_GateComp
|
||||
modules.MCompGate
|
||||
service base.IRPCXService
|
||||
module *User
|
||||
hero comm.IHero
|
||||
}
|
||||
|
||||
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.module = module.(*User)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
err = this.MCompGate.Start()
|
||||
var module core.IModule
|
||||
|
||||
//get module hero
|
||||
|
@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
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) {
|
||||
err = this.Model_Comp.Init(service, module, comp, options)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = "session"
|
||||
return
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ const ( //Redis
|
||||
)
|
||||
|
||||
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) {
|
||||
err = this.Model_Comp.Init(service, module, comp, options)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = "user"
|
||||
return
|
||||
}
|
||||
|
175
pb/comm.pb.go
175
pb/comm.pb.go
@ -160,8 +160,9 @@ type AgentMessage struct {
|
||||
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId"`
|
||||
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId"`
|
||||
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"`
|
||||
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method"`
|
||||
Message *anypb.Any `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message"`
|
||||
MainType string `protobuf:"bytes,5,opt,name=MainType,proto3" json:"MainType"`
|
||||
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() {
|
||||
@ -224,9 +225,16 @@ func (x *AgentMessage) GetGatewayServiceId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentMessage) GetMethod() string {
|
||||
func (x *AgentMessage) GetMainType() string {
|
||||
if x != nil {
|
||||
return x.Method
|
||||
return x.MainType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentMessage) GetSubType() string {
|
||||
if x != nil {
|
||||
return x.SubType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -245,8 +253,9 @@ type RPCMessageReply struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"`
|
||||
Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message"`
|
||||
Data string `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data"`
|
||||
ErrorMessage string `protobuf:"bytes,2,opt,name=ErrorMessage,proto3" json:"ErrorMessage"`
|
||||
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() {
|
||||
@ -288,20 +297,27 @@ func (x *RPCMessageReply) GetCode() ErrorCode {
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) GetMessage() string {
|
||||
func (x *RPCMessageReply) GetErrorMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
return x.ErrorMessage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) GetData() string {
|
||||
func (x *RPCMessageReply) GetErrorData() string {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
return x.ErrorData
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) GetReply() *UserMessage {
|
||||
if x != nil {
|
||||
return x.Reply
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//用户代理绑定Uid请求
|
||||
type AgentBuildReq struct {
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
@ -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,
|
||||
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,
|
||||
0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07,
|
||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
|
||||
0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65,
|
||||
0x18, 0x05, 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, 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,
|
||||
0x41, 0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5f, 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,
|
||||
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,
|
||||
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, 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, 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,
|
||||
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 (
|
||||
@ -836,14 +858,15 @@ var file_comm_proto_depIdxs = []int32{
|
||||
11, // 0: UserMessage.data:type_name -> google.protobuf.Any
|
||||
11, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
|
||||
12, // 2: RPCMessageReply.Code:type_name -> ErrorCode
|
||||
11, // 3: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 4: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 5: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
1, // 3: RPCMessageReply.Reply:type_name -> UserMessage
|
||||
11, // 4: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 5: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 6: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension 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() }
|
||||
|
@ -18,8 +18,9 @@ message AgentMessage {
|
||||
string UserSessionId = 2;
|
||||
string UserId = 3;
|
||||
string GatewayServiceId = 4;
|
||||
string Method = 5;
|
||||
google.protobuf.Any Message = 6;
|
||||
string MainType = 5;
|
||||
string SubType = 6;
|
||||
google.protobuf.Any Message = 7;
|
||||
}
|
||||
|
||||
// RPC 服务固定回复结构
|
||||
|
@ -34,8 +34,10 @@ func NewGateRouteComp() comm.ISC_GateRouteComp {
|
||||
//用户协议处理函数注册的反射对象
|
||||
type msghandle struct {
|
||||
rcvr reflect.Value
|
||||
msgType reflect.Type
|
||||
fn reflect.Method
|
||||
msgType reflect.Type //消息请求类型
|
||||
replyType reflect.Type //消息回应类型
|
||||
check reflect.Method //校验函数
|
||||
handle reflect.Method //处理函数
|
||||
}
|
||||
|
||||
//服务网关组件
|
||||
@ -43,7 +45,6 @@ type SCompGateRoute struct {
|
||||
cbase.ServiceCompBase
|
||||
service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口
|
||||
mrlock sync.RWMutex //msghandles 对象的锁
|
||||
msgcheck 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) {
|
||||
err = this.ServiceCompBase.Init(service, comp, options)
|
||||
this.service = service.(base.IRPCXService)
|
||||
this.msgcheck = make(map[string]*msghandle)
|
||||
this.msghandles = make(map[string]*msghandle)
|
||||
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_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知
|
||||
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
|
||||
}
|
||||
|
||||
//业务模块注册用户消息处理路由
|
||||
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)
|
||||
this.mrlock.RLock()
|
||||
_, ok := this.msghandles[methodName]
|
||||
@ -97,26 +83,9 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value,
|
||||
this.msghandles[methodName] = &msghandle{
|
||||
rcvr: comp,
|
||||
msgType: msg,
|
||||
fn: fn,
|
||||
}
|
||||
this.mrlock.Unlock()
|
||||
}
|
||||
|
||||
//业务模块注册用户消息处理路由
|
||||
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,
|
||||
replyType: replyType,
|
||||
check: check,
|
||||
handle: handele,
|
||||
}
|
||||
this.mrlock.Unlock()
|
||||
}
|
||||
@ -128,15 +97,15 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
||||
buf := make([]byte, 1024)
|
||||
l := runtime.Stack(buf, false)
|
||||
reply.Code = pb.ErrorCode_Exception
|
||||
reply.Message = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||
log.Errorf("HandleUserMsg:%s err:%s", args.Method, reply.Message)
|
||||
reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||
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()
|
||||
msghandle, ok := this.msghandles[args.Method]
|
||||
msgcheck := this.msgcheck[args.Method]
|
||||
msghandle, ok := this.msghandles[method]
|
||||
this.mrlock.RUnlock()
|
||||
if ok {
|
||||
//封装用户会话
|
||||
@ -144,24 +113,27 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
||||
//序列化用户消息对象
|
||||
msg := reflect.New(msghandle.msgType.Elem()).Interface()
|
||||
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
|
||||
}
|
||||
|
||||
//序列化用户消息对象
|
||||
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)
|
||||
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.Message = pb.GetErrorCodeMsg(code.Code)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(code.Code)
|
||||
if code.Data != nil { //处理错误附加数据 采用json 序列化为string
|
||||
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
|
||||
} else {
|
||||
reply.Data = codec.BytesToString(d)
|
||||
reply.ErrorData = codec.BytesToString(d)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -169,12 +141,12 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
||||
//校验结果成功 处理临时数据转移
|
||||
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())
|
||||
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.Message = pb.GetErrorCodeMsg(errcode)
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(errcode)
|
||||
return nil
|
||||
}
|
||||
} else { //未找到消息处理函数
|
||||
|
Loading…
Reference in New Issue
Block a user