From 7326b8209d6669ccbabdc5dad081ea95658e9d75 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 22 Jul 2022 14:29:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=9B=BE=E9=89=B4?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 14 ++++ modules/user/api.go | 1 + modules/user/api_gettujian.go | 33 ++++++++ pb/proto/user/user_msg.proto | 8 ++ pb/proto/userexpand.proto | 1 + pb/user_msg.pb.go | 151 ++++++++++++++++++++++++++++++---- pb/userexpand.pb.go | 50 +++++++---- 7 files changed, 223 insertions(+), 35 deletions(-) create mode 100644 modules/user/api_gettujian.go diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 02f4aaa22..ffff648bc 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -101,6 +101,20 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) (hero *pb.DBHe func (this *ModelHero) initHeroOverlying(uid string, heroCfgId, count int32) (hero *pb.DBHero, err error) { hero = this.initHero(uid, heroCfgId) if hero != nil { + // 添加图鉴 + if result, err1 := this.GetUserExpand(uid); err1 == nil { + sz := make(map[int32]bool, 0) + for k := range result.GetTujian() { + sz[k] = true + } + if _, ok := result.GetTujian()[heroCfgId]; !ok { + sz[heroCfgId] = true + initUpdate := map[string]interface{}{ + "tujian": sz, + } + this.ChanageUserExpand(uid, initUpdate) + } + } hero.SameCount += count if err = this.moduleHero.modelHero.AddList(uid, hero.Id, hero); err != nil { this.moduleHero.Errorf("%v", err) diff --git a/modules/user/api.go b/modules/user/api.go index 84facd0b2..507517801 100644 --- a/modules/user/api.go +++ b/modules/user/api.go @@ -17,6 +17,7 @@ const ( UserSubTypeUpdatesetting = "updatesetting" //更新设置 UserSubTypeVeriCode = "vericode" //验证码 UserSubTypeInitData = "initdata" //初始化用户 + UserGetTujianResp = "gettujian" //获取图鉴信息 ) type apiComp struct { diff --git a/modules/user/api_gettujian.go b/modules/user/api_gettujian.go new file mode 100644 index 000000000..9e48d3bc6 --- /dev/null +++ b/modules/user/api_gettujian.go @@ -0,0 +1,33 @@ +package user + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +func (this *apiComp) GetTujianCheck(session comm.IUserSession, req *pb.UserGetTujianReq) (code pb.ErrorCode) { + return +} + +func (this *apiComp) GetTujian(session comm.IUserSession, req *pb.UserGetTujianReq) (code pb.ErrorCode, data proto.Message) { + if code = this.GetTujianCheck(session, req); code != pb.ErrorCode_Success { + return + } + + rsp := &pb.UserGetTujianResp{} + if result, err := this.module.modelUser.GetUserExpand(session.GetUserId()); err != nil { + this.module.Errorf("err:%v", err) + return + } else { + for k := range result.Tujian { + rsp.Heroids = append(rsp.Heroids, k) + } + } + err := session.SendMsg(string(this.module.GetType()), UserGetTujianResp, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + } + return +} diff --git a/pb/proto/user/user_msg.proto b/pb/proto/user/user_msg.proto index caef23a01..fdcd3bfdb 100644 --- a/pb/proto/user/user_msg.proto +++ b/pb/proto/user/user_msg.proto @@ -89,4 +89,12 @@ message UserModifynameReq { message UserModifynameResp { string uid = 1; uint32 count = 2; //剩余修改次数 +} + +message UserGetTujianReq{ + +} + +message UserGetTujianResp{ + repeated int32 heroids = 1; } \ No newline at end of file diff --git a/pb/proto/userexpand.proto b/pb/proto/userexpand.proto index fe38ed0d7..d76675dc1 100644 --- a/pb/proto/userexpand.proto +++ b/pb/proto/userexpand.proto @@ -10,4 +10,5 @@ message DBUserExpand { uint32 initdataCount = 5; //今日初始累计次数 int32 chatchannel = 6; //跨服聊天频道 int32 modifynameCount = 7; //修改昵称次数 + map tujian = 8; // 图鉴 } diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index e5d9739c5..71371735c 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -1074,6 +1074,91 @@ func (x *UserModifynameResp) GetCount() uint32 { return 0 } +type UserGetTujianReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UserGetTujianReq) Reset() { + *x = UserGetTujianReq{} + if protoimpl.UnsafeEnabled { + mi := &file_user_user_msg_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserGetTujianReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserGetTujianReq) ProtoMessage() {} + +func (x *UserGetTujianReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_msg_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserGetTujianReq.ProtoReflect.Descriptor instead. +func (*UserGetTujianReq) Descriptor() ([]byte, []int) { + return file_user_user_msg_proto_rawDescGZIP(), []int{22} +} + +type UserGetTujianResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Heroids []int32 `protobuf:"varint,1,rep,packed,name=heroids,proto3" json:"heroids"` +} + +func (x *UserGetTujianResp) Reset() { + *x = UserGetTujianResp{} + if protoimpl.UnsafeEnabled { + mi := &file_user_user_msg_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserGetTujianResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserGetTujianResp) ProtoMessage() {} + +func (x *UserGetTujianResp) ProtoReflect() protoreflect.Message { + mi := &file_user_user_msg_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserGetTujianResp.ProtoReflect.Descriptor instead. +func (*UserGetTujianResp) Descriptor() ([]byte, []int) { + return file_user_user_msg_proto_rawDescGZIP(), []int{23} +} + +func (x *UserGetTujianResp) GetHeroids() []int32 { + if x != nil { + return x.Heroids + } + return nil +} + var File_user_user_msg_proto protoreflect.FileDescriptor var file_user_user_msg_proto_rawDesc = []byte{ @@ -1147,8 +1232,12 @@ var file_user_user_msg_proto_rawDesc = []byte{ 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e, 0x61, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x47, 0x65, 0x74, + 0x54, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x22, 0x2d, 0x0a, 0x11, 0x55, 0x73, 0x65, + 0x72, 0x47, 0x65, 0x74, 0x54, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x18, + 0x0a, 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, + 0x07, 0x68, 0x65, 0x72, 0x6f, 0x69, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1163,7 +1252,7 @@ func file_user_user_msg_proto_rawDescGZIP() []byte { return file_user_user_msg_proto_rawDescData } -var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 22) +var file_user_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 24) var file_user_user_msg_proto_goTypes = []interface{}{ (*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginResp)(nil), // 1: UserLoginResp @@ -1187,22 +1276,24 @@ var file_user_user_msg_proto_goTypes = []interface{}{ (*UserInitdataResp)(nil), // 19: UserInitdataResp (*UserModifynameReq)(nil), // 20: UserModifynameReq (*UserModifynameResp)(nil), // 21: UserModifynameResp - (*DBUser)(nil), // 22: DBUser - (*DBUserExpand)(nil), // 23: DBUserExpand - (ErrorCode)(0), // 24: ErrorCode - (*CacheUser)(nil), // 25: CacheUser - (*UserAssets)(nil), // 26: UserAssets - (*DBUserSetting)(nil), // 27: DBUserSetting + (*UserGetTujianReq)(nil), // 22: UserGetTujianReq + (*UserGetTujianResp)(nil), // 23: UserGetTujianResp + (*DBUser)(nil), // 24: DBUser + (*DBUserExpand)(nil), // 25: DBUserExpand + (ErrorCode)(0), // 26: ErrorCode + (*CacheUser)(nil), // 27: CacheUser + (*UserAssets)(nil), // 28: UserAssets + (*DBUserSetting)(nil), // 29: DBUserSetting } var file_user_user_msg_proto_depIdxs = []int32{ - 22, // 0: UserLoginResp.data:type_name -> DBUser - 23, // 1: UserLoginResp.ex:type_name -> DBUserExpand - 24, // 2: UserRegisterResp.Code:type_name -> ErrorCode - 25, // 3: UserLoadResp.data:type_name -> CacheUser - 26, // 4: UserAddResReq.res:type_name -> UserAssets - 26, // 5: UserAddResResp.res:type_name -> UserAssets - 27, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting - 27, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting + 24, // 0: UserLoginResp.data:type_name -> DBUser + 25, // 1: UserLoginResp.ex:type_name -> DBUserExpand + 26, // 2: UserRegisterResp.Code:type_name -> ErrorCode + 27, // 3: UserLoadResp.data:type_name -> CacheUser + 28, // 4: UserAddResReq.res:type_name -> UserAssets + 28, // 5: UserAddResResp.res:type_name -> UserAssets + 29, // 6: UserGetSettingResp.setting:type_name -> DBUserSetting + 29, // 7: UserUpdateSettingReq.setting:type_name -> DBUserSetting 8, // [8:8] is the sub-list for method output_type 8, // [8:8] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -1484,6 +1575,30 @@ func file_user_user_msg_proto_init() { return nil } } + file_user_user_msg_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserGetTujianReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_user_msg_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserGetTujianResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1491,7 +1606,7 @@ func file_user_user_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_user_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 22, + NumMessages: 24, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/userexpand.pb.go b/pb/userexpand.pb.go index 026506f28..2dd722859 100644 --- a/pb/userexpand.pb.go +++ b/pb/userexpand.pb.go @@ -26,13 +26,14 @@ type DBUserExpand struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //主键id - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id - Lastreadnotiftime int64 `protobuf:"varint,3,opt,name=lastreadnotiftime,proto3" json:"lastreadnotiftime"` //最后阅读公告时间 - LastInitdataTime int64 `protobuf:"varint,4,opt,name=lastInitdataTime,proto3" json:"lastInitdataTime"` //上次初始数据时间 - InitdataCount uint32 `protobuf:"varint,5,opt,name=initdataCount,proto3" json:"initdataCount"` //今日初始累计次数 - Chatchannel int32 `protobuf:"varint,6,opt,name=chatchannel,proto3" json:"chatchannel"` //跨服聊天频道 - ModifynameCount int32 `protobuf:"varint,7,opt,name=modifynameCount,proto3" json:"modifynameCount"` //修改昵称次数 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //主键id + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id + Lastreadnotiftime int64 `protobuf:"varint,3,opt,name=lastreadnotiftime,proto3" json:"lastreadnotiftime"` //最后阅读公告时间 + LastInitdataTime int64 `protobuf:"varint,4,opt,name=lastInitdataTime,proto3" json:"lastInitdataTime"` //上次初始数据时间 + InitdataCount uint32 `protobuf:"varint,5,opt,name=initdataCount,proto3" json:"initdataCount"` //今日初始累计次数 + Chatchannel int32 `protobuf:"varint,6,opt,name=chatchannel,proto3" json:"chatchannel"` //跨服聊天频道 + ModifynameCount int32 `protobuf:"varint,7,opt,name=modifynameCount,proto3" json:"modifynameCount"` //修改昵称次数 + Tujian map[int32]bool `protobuf:"bytes,8,rep,name=tujian,proto3" json:"tujian" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 图鉴 } func (x *DBUserExpand) Reset() { @@ -116,11 +117,18 @@ func (x *DBUserExpand) GetModifynameCount() int32 { return 0 } +func (x *DBUserExpand) GetTujian() map[int32]bool { + if x != nil { + return x.Tujian + } + return nil +} + var File_userexpand_proto protoreflect.FileDescriptor var file_userexpand_proto_rawDesc = []byte{ 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xfc, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x45, 0x78, 0x70, + 0x74, 0x6f, 0x22, 0xea, 0x02, 0x0a, 0x0c, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, @@ -136,8 +144,14 @@ var file_userexpand_proto_rawDesc = []byte{ 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x28, 0x0a, 0x0f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x6e, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x75, 0x6e, - 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x74, 0x12, 0x31, 0x0a, 0x06, 0x74, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x18, 0x08, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, + 0x2e, 0x54, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x74, 0x75, + 0x6a, 0x69, 0x61, 0x6e, 0x1a, 0x39, 0x0a, 0x0b, 0x54, 0x75, 0x6a, 0x69, 0x61, 0x6e, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -152,16 +166,18 @@ func file_userexpand_proto_rawDescGZIP() []byte { return file_userexpand_proto_rawDescData } -var file_userexpand_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_userexpand_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_userexpand_proto_goTypes = []interface{}{ (*DBUserExpand)(nil), // 0: DBUserExpand + nil, // 1: DBUserExpand.TujianEntry } var file_userexpand_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: DBUserExpand.tujian:type_name -> DBUserExpand.TujianEntry + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_userexpand_proto_init() } @@ -189,7 +205,7 @@ func file_userexpand_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_userexpand_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, From 9f6f4b5bc030948161a69da7ab195e88d8dd8330 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 22 Jul 2022 15:17:49 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=B3=A8=E5=86=8Cgm=20api=20=E5=92=8C=E6=AD=A6=E5=99=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/const.go | 19 +++++++++++-------- modules/comp_gate.go | 7 ------- modules/equipment/api_equip.go | 17 +++++++++++------ modules/gateway/agentmgr_comp.go | 4 ++-- modules/gm/api.go | 31 ++++++++++++++++++++++++++++--- services/comp_gateroute.go | 4 ++-- 6 files changed, 54 insertions(+), 28 deletions(-) diff --git a/comm/const.go b/comm/const.go index 5ff2c5b58..c362064c0 100644 --- a/comm/const.go +++ b/comm/const.go @@ -48,14 +48,17 @@ const ( //RPC服务接口定义处 const ( //Rpc - Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由 - Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id - Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id - Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息 - Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息 - Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息 - Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 - Rpc_NoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 + //Gateway + Rpc_GatewayRoute core.Rpc_Key = "Rpc_GatewayRoute" //网关路由 + Rpc_GatewayAgentBind core.Rpc_Key = "Rpc_GatewayAgentBind" //代理绑定 绑定用户Id + Rpc_GatewayAgentUnBind core.Rpc_Key = "Rpc_GatewayAgentUnBind" //代理解绑 解绑用户Id + Rpc_GatewayAgentSendMsg core.Rpc_Key = "Rpc_GatewayAgentSendMsg" //代理发送消息 向用户发送消息 + Rpc_GatewaySendBatchMsg core.Rpc_Key = "Rpc_GatewaySendBatchMsg" //向多个用户发送消息 + Rpc_GatewaySendRadioMsg core.Rpc_Key = "Rpc_GatewaySendRadioMsg" //广播消息 + Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 + Rpc_GatewayNoticeUserClose core.Rpc_Key = "Rpc_NoticeUserClose" //通知用户离线 + //Chat + Rpc_ReleaseSystemMessage core.Rpc_Key = "Rpc_ReleaseSystemMessage" //发布系统消息 ) //事件类型定义处 diff --git a/modules/comp_gate.go b/modules/comp_gate.go index 135938dae..0a3fbb23f 100644 --- a/modules/comp_gate.go +++ b/modules/comp_gate.go @@ -100,13 +100,6 @@ func (this *MCompGate) reflectionRouteHandle(typ reflect.Type, method reflect.Me log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) return } - // if agrType.Kind() != reflect.Ptr { - // return - // } - // if !this.isExportedOrBuiltinType(agrType) { - // return - // } - if mtype.NumOut() != 2 { log.Panicf("反射注册用户处理函数错误 [%s-%s] Api接口格式错误", this.module.GetType(), mname) return diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 206e69eff..3b0516db5 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -46,6 +46,8 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) code = pb.ErrorCode_EquipmentOnFoundEquipment return } + } else { + equipments[i] = nil } } //获取英雄数据 @@ -113,12 +115,15 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) } } //更新装备数据加成 - if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code == pb.ErrorCode_Success { - if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { - log.Errorf("Equip err%v", err) - code = pb.ErrorCode_SystemError - return - } + if code = this.module.ModuleHero.UpdateEquipment(session, hero, equipments); code != pb.ErrorCode_Success { + log.Errorf("Equip ModuleHero UpdateEquipment code%v", code) + return + } + //同步数据 + if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil { + log.Errorf("Equip err%v", err) + code = pb.ErrorCode_SystemError + return } session.SendMsg(string(this.module.GetType()), "equip", &pb.EquipmentEquipResp{Equipments: updatequipment}) return diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 6aeb48fa6..a36c5bf0f 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -44,7 +44,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) { this.agents.Delete(a.SessionId()) if a.UserId() != "" { //登录用户 通知业务服务处理玩家离线相关 reply := &pb.RPCMessageReply{} - if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{ + if _, err := this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Worker, a.WorkerId()), string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{ Ip: a.IP(), ServiceTag: this.service.GetTag(), GatewayServiceId: this.service.GetId(), @@ -54,7 +54,7 @@ func (this *AgentMgrComp) DisConnect(a IAgent) { log.Errorf("uId:%s Rpc_NoticeUserClose err:%v", a.UserId(), err) } //推送跨服集群处理 - if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_NoticeUserClose), &pb.NoticeUserCloseReq{ + if _, err := this.service.AcrossClusterRpcGo(context.Background(), this.options.SpanServiceTag, comm.Service_Worker, string(comm.Rpc_GatewayNoticeUserClose), &pb.NoticeUserCloseReq{ Ip: a.IP(), ServiceTag: this.service.GetTag(), GatewayServiceId: this.service.GetId(), diff --git a/modules/gm/api.go b/modules/gm/api.go index 6e140a486..2ec464dd4 100644 --- a/modules/gm/api.go +++ b/modules/gm/api.go @@ -4,6 +4,9 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/gin" + "go_dreamfactory/lego/sys/gin/engine" + "reflect" + "strings" ) /* @@ -22,8 +25,30 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core this.options = options.(*Options) this.module = module.(*GM) this.gin, err = gin.NewSys(gin.SetListenPort(this.options.Port)) - this.gin.POST("/register", this.Register) - this.gin.GET("/serverlist", this.ServerList) - this.gin.GET("/createnotify", this.CreateNotify) + this.suitableMethods() //发射注册api return } + +func (this *Api_Comp) suitableMethods() { + typ := reflect.TypeOf(this) + vof := reflect.ValueOf(this) + for m := 0; m < typ.NumMethod(); m++ { + method := typ.Method(m) + mname := method.Name + mtype := method.Type + if method.PkgPath != "" { + continue + } + if mtype.NumIn() != 2 { + continue + } + context := mtype.In(1) + if context.String() != "*engine.Context" { + continue + } + if mtype.NumOut() != 0 { + continue + } + this.gin.POST(strings.ToLower(mname), vof.MethodByName(mname).Interface().(func(*engine.Context))) + } +} diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index af6455cdc..013741c34 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -84,8 +84,8 @@ func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, //组件启动时注册rpc服务监听 func (this *SCompGateRoute) Start() (err error) { - this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 - this.service.RegisterFunctionName(string(comm.Rpc_NoticeUserClose), this.NoticeUserClose) //注册用户离线通知 + this.service.RegisterFunctionName(string(comm.Rpc_GatewayRoute), this.ReceiveMsg) //注册网关路由接收接口 + this.service.RegisterFunctionName(string(comm.Rpc_GatewayNoticeUserClose), this.NoticeUserClose) //注册用户离线通知 err = this.ServiceCompBase.Start() return }