From 17ac51b6760cd583ac025f17779934aa9b1b9614 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 30 Jun 2022 13:47:30 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0pb=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/notify.go | 2 +- cmd/robot/robot.go | 2 +- comm/const.go | 2 +- modules/gateway/agent.go | 4 +- pb/hero_msg.pb.go | 152 +++++++++++++------------------ pb/notify_msg.pb.go | 61 +++++++------ pb/proto/notify/notify_msg.proto | 4 +- services/comp_gateroute.go | 4 +- 8 files changed, 104 insertions(+), 127 deletions(-) diff --git a/cmd/robot/notify.go b/cmd/robot/notify.go index 89847d73a..331b4e651 100644 --- a/cmd/robot/notify.go +++ b/cmd/robot/notify.go @@ -10,7 +10,7 @@ var notify_builders = []*builder{ //create mainType: comm.MainTypeNotify, subType: comm.SubTypeErrorNotify, - rsp: &pb.ErrorNotify{}, + rsp: &pb.NotifyErrorNotifyPush{}, enabled: true, }, } diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 8f6ca73ce..d3311cad1 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -211,7 +211,7 @@ func (r *Robot) AccountRegister(account string, sid int32) { //打印响应 func printReply(msg *pb.UserMessage, builder *builder) { - if m, ok := builder.rsp.(*pb.ErrorNotify); ok { + if m, ok := builder.rsp.(*pb.NotifyErrorNotifyPush); ok { var tt time.Duration if builder.start.IsZero() { tt = time.Duration(0) diff --git a/comm/const.go b/comm/const.go index a8ac4a08b..19d5df06e 100644 --- a/comm/const.go +++ b/comm/const.go @@ -38,7 +38,7 @@ const ( ModuleEquipment core.M_Modules = "equipment" //装备模块 ModuleHero core.M_Modules = "hero" //英雄模块 ModuleForum core.M_Modules = "forum" //论坛模块 - ModuleItems core.M_Modules = "item" + ModuleItems core.M_Modules = "items" //道具模块 ) //RPC服务接口定义处 diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index f4106296c..69e32f76d 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -81,7 +81,7 @@ locp: break locp } } else { - data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode_SecKeyInvalid}) + data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode_SecKeyInvalid}) if err = this.WriteMsg(&pb.UserMessage{ MainType: comm.MainTypeNotify, SubType: comm.SubTypeErrorNotify, @@ -232,7 +232,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { return } if reply.Code != pb.ErrorCode_Success { - data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())}) + data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())}) err = this.WriteMsg(&pb.UserMessage{ MainType: comm.MainTypeNotify, SubType: comm.SubTypeErrorNotify, diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index b36b06e1c..535178fed 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1323,64 +1323,40 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x0a, 0x1a, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x65, 0x73, 0x6f, 0x6e, 0x61, 0x6e, 0x63, 0x65, 0x55, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, - 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, 0x16, 0x0a, 0x06, - 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x65, 0x6e, - 0x65, 0x72, 0x67, 0x79, 0x12, 0x2a, 0x0a, 0x0a, 0x75, 0x70, 0x53, 0x74, 0x61, 0x72, 0x43, 0x61, - 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, - 0x48, 0x65, 0x72, 0x6f, 0x52, 0x0a, 0x75, 0x70, 0x53, 0x74, 0x61, 0x72, 0x43, 0x61, 0x72, 0x64, - 0x22, 0x34, 0x0a, 0x14, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x6f, 0x6e, 0x67, 0x6d, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, - 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, - 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x22, 0x4f, 0x0a, 0x15, 0x48, 0x65, 0x72, 0x6f, 0x47, 0x6f, - 0x6e, 0x67, 0x6d, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, - 0x1e, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, - 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x12, - 0x16, 0x0a, 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x65, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x22, 0x70, 0x0a, 0x18, 0x48, 0x65, 0x72, 0x6f, 0x47, - 0x6f, 0x6e, 0x67, 0x6d, 0x69, 0x6e, 0x67, 0x55, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, - 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, - 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x75, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, 0x67, 0x79, 0x12, - 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x07, 0x75, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x3b, 0x0a, 0x19, 0x48, 0x65, 0x72, - 0x6f, 0x47, 0x6f, 0x6e, 0x67, 0x6d, 0x69, 0x6e, 0x67, 0x55, 0x73, 0x65, 0x45, 0x6e, 0x65, 0x72, - 0x67, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, - 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x5a, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x4a, 0x75, - 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, - 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, - 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x12, 0x2a, 0x0a, 0x09, 0x63, 0x6f, 0x73, 0x74, 0x49, 0x74, - 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x49, - 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x09, 0x63, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, - 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, - 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x0f, 0x0a, 0x0d, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, - 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, - 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, - 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a, - 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x16, 0x0a, - 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, - 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, - 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x79, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f, - 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, - 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 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, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x79, 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, 0x05, 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, + 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x5a, 0x0a, 0x0e, + 0x48, 0x65, 0x72, 0x6f, 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x12, 0x1c, + 0x0a, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x68, 0x65, 0x72, 0x6f, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x12, 0x2a, 0x0a, 0x09, + 0x63, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x09, 0x63, + 0x6f, 0x73, 0x74, 0x49, 0x74, 0x6d, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x0f, 0x48, 0x65, 0x72, 0x6f, + 0x4a, 0x75, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x68, + 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x44, + 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x22, 0x0f, 0x0a, 0x0d, 0x48, + 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x71, 0x22, 0x34, 0x0a, 0x0e, + 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x6f, 0x75, 0x6b, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, + 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, + 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x42, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, + 0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x0c, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x3a, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x70, 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x70, + 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x43, 0x0a, 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, + 0x62, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x2e, 0x41, + 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x0b, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x1a, 0x3b, 0x0a, 0x0d, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 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, 0x05, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3e, 0x0a, 0x10, 0x41, 0x64, 0x64, + 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 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, 0x05, 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 ( @@ -1397,32 +1373,32 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_hero_hero_msg_proto_goTypes = []interface{}{ - (*HeroInfoReq)(nil), // 0: pb.HeroInfoReq - (*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp - (*HeroListReq)(nil), // 2: pb.HeroListReq - (*HeroListRsp)(nil), // 3: pb.HeroListRsp - (*ItemData)(nil), // 4: pb.ItemData - (*HeroStrengthenUplvReq)(nil), // 5: pb.HeroStrengthenUplvReq - (*HeroStrengthenUplvResp)(nil), // 6: pb.HeroStrengthenUplvResp - (*CostCardData)(nil), // 7: pb.CostCardData - (*HeroStrengthenUpStarReq)(nil), // 8: pb.HeroStrengthenUpStarReq - (*HeroStrengthenUpStarResp)(nil), // 9: pb.HeroStrengthenUpStarResp - (*HeroStrengthenUpSkillReq)(nil), // 10: pb.HeroStrengthenUpSkillReq - (*HeroStrengthenUpSkillResp)(nil), // 11: pb.HeroStrengthenUpSkillResp - (*HeroGongmingReq)(nil), // 12: pb.HeroGongmingReq - (*HeroGongmingResp)(nil), // 13: pb.HeroGongmingResp - (*HeroGongmingResetReq)(nil), // 14: pb.HeroGongmingResetReq - (*HeroGongmingResetResp)(nil), // 15: pb.HeroGongmingResetResp - (*HeroGongmingUseEnergyReq)(nil), // 16: pb.HeroGongmingUseEnergyReq - (*HeroGongmingUseEnergyResp)(nil), // 17: pb.HeroGongmingUseEnergyResp - (*HeroJuexingReq)(nil), // 18: pb.HeroJuexingReq - (*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp - (*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq - (*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp - (*HeroProperty)(nil), // 22: pb.HeroProperty - nil, // 23: pb.HeroProperty.PropertyEntry - nil, // 24: pb.HeroProperty.AddPropertyEntry - (*DBHero)(nil), // 25: pb.DBHero + (*HeroInfoReq)(nil), // 0: pb.HeroInfoReq + (*HeroInfoRsp)(nil), // 1: pb.HeroInfoRsp + (*HeroListReq)(nil), // 2: pb.HeroListReq + (*HeroListRsp)(nil), // 3: pb.HeroListRsp + (*ItemData)(nil), // 4: pb.ItemData + (*HeroStrengthenUplvReq)(nil), // 5: pb.HeroStrengthenUplvReq + (*HeroStrengthenUplvResp)(nil), // 6: pb.HeroStrengthenUplvResp + (*CostCardData)(nil), // 7: pb.CostCardData + (*HeroStrengthenUpStarReq)(nil), // 8: pb.HeroStrengthenUpStarReq + (*HeroStrengthenUpStarResp)(nil), // 9: pb.HeroStrengthenUpStarResp + (*HeroStrengthenUpSkillReq)(nil), // 10: pb.HeroStrengthenUpSkillReq + (*HeroStrengthenUpSkillResp)(nil), // 11: pb.HeroStrengthenUpSkillResp + (*HeroResonanceReq)(nil), // 12: pb.HeroResonanceReq + (*HeroResonanceResp)(nil), // 13: pb.HeroResonanceResp + (*HeroResonanceResetReq)(nil), // 14: pb.HeroResonanceResetReq + (*HeroResonanceResetResp)(nil), // 15: pb.HeroResonanceResetResp + (*HeroResonanceUseEnergyReq)(nil), // 16: pb.HeroResonanceUseEnergyReq + (*HeroResonanceUseEnergyResp)(nil), // 17: pb.HeroResonanceUseEnergyResp + (*HeroJuexingReq)(nil), // 18: pb.HeroJuexingReq + (*HeroJuexingResp)(nil), // 19: pb.HeroJuexingResp + (*HeroChoukaReq)(nil), // 20: pb.HeroChoukaReq + (*HeroChoukaResp)(nil), // 21: pb.HeroChoukaResp + (*HeroProperty)(nil), // 22: pb.HeroProperty + nil, // 23: pb.HeroProperty.PropertyEntry + nil, // 24: pb.HeroProperty.AddPropertyEntry + (*DBHero)(nil), // 25: pb.DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ 25, // 0: pb.HeroInfoRsp.base:type_name -> pb.DBHero @@ -1432,10 +1408,10 @@ var file_hero_hero_msg_proto_depIdxs = []int32{ 7, // 4: pb.HeroStrengthenUpStarReq.heroRace:type_name -> pb.CostCardData 25, // 5: pb.HeroStrengthenUpStarResp.hero:type_name -> pb.DBHero 25, // 6: pb.HeroStrengthenUpSkillResp.hero:type_name -> pb.DBHero - 25, // 7: pb.HeroGongmingResp.hero:type_name -> pb.DBHero - 25, // 8: pb.HeroGongmingResp.upStarCard:type_name -> pb.DBHero - 25, // 9: pb.HeroGongmingResetResp.hero:type_name -> pb.DBHero - 25, // 10: pb.HeroGongmingUseEnergyResp.hero:type_name -> pb.DBHero + 25, // 7: pb.HeroResonanceResp.hero:type_name -> pb.DBHero + 25, // 8: pb.HeroResonanceResp.upStarCard:type_name -> pb.DBHero + 25, // 9: pb.HeroResonanceResetResp.hero:type_name -> pb.DBHero + 25, // 10: pb.HeroResonanceUseEnergyResp.hero:type_name -> pb.DBHero 4, // 11: pb.HeroJuexingReq.costItmes:type_name -> pb.ItemData 25, // 12: pb.HeroJuexingResp.hero:type_name -> pb.DBHero 25, // 13: pb.HeroChoukaResp.heroes:type_name -> pb.DBHero diff --git a/pb/notify_msg.pb.go b/pb/notify_msg.pb.go index b5a7e3566..52fdaef1a 100644 --- a/pb/notify_msg.pb.go +++ b/pb/notify_msg.pb.go @@ -20,8 +20,8 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -//统一错误码返回 -type ErrorNotify struct { +//统一错误码推送 +type NotifyErrorNotifyPush struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -33,8 +33,8 @@ type ErrorNotify struct { Data string `protobuf:"bytes,6,opt,name=Data,proto3" json:"Data"` // 错误数据 } -func (x *ErrorNotify) Reset() { - *x = ErrorNotify{} +func (x *NotifyErrorNotifyPush) Reset() { + *x = NotifyErrorNotifyPush{} if protoimpl.UnsafeEnabled { mi := &file_notify_notify_msg_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -42,13 +42,13 @@ func (x *ErrorNotify) Reset() { } } -func (x *ErrorNotify) String() string { +func (x *NotifyErrorNotifyPush) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ErrorNotify) ProtoMessage() {} +func (*NotifyErrorNotifyPush) ProtoMessage() {} -func (x *ErrorNotify) ProtoReflect() protoreflect.Message { +func (x *NotifyErrorNotifyPush) ProtoReflect() protoreflect.Message { mi := &file_notify_notify_msg_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -60,40 +60,40 @@ func (x *ErrorNotify) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ErrorNotify.ProtoReflect.Descriptor instead. -func (*ErrorNotify) Descriptor() ([]byte, []int) { +// Deprecated: Use NotifyErrorNotifyPush.ProtoReflect.Descriptor instead. +func (*NotifyErrorNotifyPush) Descriptor() ([]byte, []int) { return file_notify_notify_msg_proto_rawDescGZIP(), []int{0} } -func (x *ErrorNotify) GetReqMainType() string { +func (x *NotifyErrorNotifyPush) GetReqMainType() string { if x != nil { return x.ReqMainType } return "" } -func (x *ErrorNotify) GetReqSubType() string { +func (x *NotifyErrorNotifyPush) GetReqSubType() string { if x != nil { return x.ReqSubType } return "" } -func (x *ErrorNotify) GetCode() ErrorCode { +func (x *NotifyErrorNotifyPush) GetCode() ErrorCode { if x != nil { return x.Code } return ErrorCode_Success } -func (x *ErrorNotify) GetMessage() string { +func (x *NotifyErrorNotifyPush) GetMessage() string { if x != nil { return x.Message } return "" } -func (x *ErrorNotify) GetData() string { +func (x *NotifyErrorNotifyPush) GetData() string { if x != nil { return x.Data } @@ -105,18 +105,19 @@ var File_notify_notify_msg_proto protoreflect.FileDescriptor var file_notify_notify_msg_proto_rawDesc = []byte{ 0x0a, 0x17, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2f, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9d, 0x01, 0x0a, 0x0b, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, - 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, - 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, - 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 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, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x01, 0x0a, 0x15, 0x4e, + 0x6f, 0x74, 0x69, 0x66, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, + 0x50, 0x75, 0x73, 0x68, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, + 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, + 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, 0x65, 0x71, 0x53, + 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, + 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, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -133,11 +134,11 @@ func file_notify_notify_msg_proto_rawDescGZIP() []byte { var file_notify_notify_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_notify_notify_msg_proto_goTypes = []interface{}{ - (*ErrorNotify)(nil), // 0: ErrorNotify - (ErrorCode)(0), // 1: ErrorCode + (*NotifyErrorNotifyPush)(nil), // 0: NotifyErrorNotifyPush + (ErrorCode)(0), // 1: ErrorCode } var file_notify_notify_msg_proto_depIdxs = []int32{ - 1, // 0: ErrorNotify.Code:type_name -> ErrorCode + 1, // 0: NotifyErrorNotifyPush.Code:type_name -> ErrorCode 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 @@ -153,7 +154,7 @@ func file_notify_notify_msg_proto_init() { file_errorcode_proto_init() if !protoimpl.UnsafeEnabled { file_notify_notify_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ErrorNotify); i { + switch v := v.(*NotifyErrorNotifyPush); i { case 0: return &v.state case 1: diff --git a/pb/proto/notify/notify_msg.proto b/pb/proto/notify/notify_msg.proto index fdd30f7d0..839c3c924 100644 --- a/pb/proto/notify/notify_msg.proto +++ b/pb/proto/notify/notify_msg.proto @@ -2,8 +2,8 @@ syntax = "proto3"; option go_package = ".;pb"; import "errorcode.proto"; -//统一错误码返回 -message ErrorNotify { +//统一错误码推送 +message NotifyErrorNotifyPush { string ReqMainType =1; // 请求协议模块 模块名 例如:user 对应项目中 user的模块 string ReqSubType = 2; // 请求协议函数 例如:login 对应项目中 user的模块中 api_login 的处理函数 ErrorCode Code = 3; // 执行返回错误码 对应 errorcode.proto 枚举 diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index af9d8d49f..3b06fb344 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -102,7 +102,6 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag log.Errorf("HandleUserMsg:[%s-%s] err:%s", args.MainType, args.SubType, reply.ErrorMessage) } }() - 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() @@ -126,7 +125,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag log.Errorf("UserMessage:%s Unmarshal err:%v", method, err) return err } - + log.Debugf("ReceiveMsg Message:[%s-%s]-%v user[%s-%s]", args.MainType, args.SubType, msg, args.UserSessionId, args.UserId) //调用校验接口 checkreturn := msghandle.check.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)}) //读取校验结果 有错误直接返回错误码给用户 @@ -159,6 +158,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag reply.Reply = session.Polls() } } else { //未找到消息处理函数 + log.Errorf("no found handle %s", method) reply.Code = pb.ErrorCode_ReqParameterError } return nil From 93570f645faa0dc7e94eaf6b9bea6f95b0edeb9a Mon Sep 17 00:00:00 2001 From: zhaocy Date: Thu, 30 Jun 2022 15:23:48 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8A=A0=E8=BD=BDglobal=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/json/game_global.json | 10 ++++++++++ modules/compconfigure.go | 28 ++++++++++++++++++++++++++++ modules/user/configure.go | 16 ++++++++++++++++ sys/configure/configure.go | 20 ++------------------ 4 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 modules/user/configure.go diff --git a/bin/json/game_global.json b/bin/json/game_global.json index 75bc5b99e..ee90363d6 100644 --- a/bin/json/game_global.json +++ b/bin/json/game_global.json @@ -28,5 +28,15 @@ "index": "task_reset", "var": "8", "intr": "日/周常任务刷新时间,8点" + }, + { + "index": "init_gold", + "var": "100000", + "intr": "初始金币" + }, + { + "index": "init_hero", + "var": "15001, 25001", + "intr": "初始英雄" } ] \ No newline at end of file diff --git a/modules/compconfigure.go b/modules/compconfigure.go index eac1f6aa3..262bd8ffc 100644 --- a/modules/compconfigure.go +++ b/modules/compconfigure.go @@ -6,6 +6,11 @@ import ( "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/log" "go_dreamfactory/sys/configure" + cfg "go_dreamfactory/sys/configure/structs" +) + +const ( + game_global = "game_global.json" ) ///配置管理基础组件 @@ -20,6 +25,7 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com this.ModuleCompBase.Init(service, module, comp, options) this.S = service.(base.IRPCXService) this.M = module.(IModule) + err = this.LoadConfigure(game_global, cfg.NewGame_global) return } @@ -44,3 +50,25 @@ func (this *MCompConfigure) LoadMultiConfigure(confs map[string]interface{}) (er func (this *MCompConfigure) GetConfigure(name string) (v interface{}, err error) { return configure.GetConfigure(name) } + +//全局配置 +func (this *MCompConfigure) GetGlobalConf(key string) string { + if v, err := this.GetConfigure(game_global); err != nil { + log.Errorf("get global conf err:%v", err) + return "" + } else { + var ( + configure *cfg.Game_global + ok bool + ) + if configure, ok = v.(*cfg.Game_global); !ok { + log.Errorf("%T no is *cfg.Game_global", v) + return "" + } + + if v, ok := configure.GetDataMap()[key]; ok { + return v.Var + } + } + return "" +} diff --git a/modules/user/configure.go b/modules/user/configure.go new file mode 100644 index 000000000..d895376ef --- /dev/null +++ b/modules/user/configure.go @@ -0,0 +1,16 @@ +package user + +import ( + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +type configureComp struct { + modules.MCompConfigure +} + +//组件初始化接口 +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + err = this.MCompConfigure.Init(service, module, comp, options) + return +} diff --git a/sys/configure/configure.go b/sys/configure/configure.go index 2690f0ba5..f97e9d94f 100644 --- a/sys/configure/configure.go +++ b/sys/configure/configure.go @@ -3,7 +3,6 @@ package configure import ( "fmt" "go_dreamfactory/lego/sys/log" - cfg "go_dreamfactory/sys/configure/structs" "io/fs" "io/ioutil" "os" @@ -31,7 +30,6 @@ func newSys(options Options) (sys *Configure, err error) { configure: make(map[string]interface{}), fileinfos: make(map[string]*FileInfo), } - err = sys.init() return } @@ -45,20 +43,6 @@ type Configure struct { fileinfos map[string]*FileInfo } -const ( - game_com = "game_com.json" -) - -func (this *Configure) init() (err error) { - - this.RegisterConfigure(game_com, cfg.NewGame_com) - // _data := this.configure[game_com] - // if _da, ok := _data.(*cfg.Game_com).GetDataMap()["max_char"]; ok { - // log.Debugf("%b==%v", ok, _da.Var) - // } - return -} - func (this *Configure) Start() (err error) { tc := time.NewTicker(time.Second * time.Duration(this.options.CheckInterval)) go func() { @@ -166,12 +150,12 @@ func (this *Configure) loaderConfigure(name string, handle *configurehandle) (er fliepath = path.Join(this.options.ConfigurePath, name) if fileInfo, err = os.Stat(fliepath); err != nil { - err = fmt.Errorf("no fond file:%s", fliepath) + err = fmt.Errorf("no found file:%s", fliepath) return } if file, err = os.Open(fliepath); err != nil { - err = fmt.Errorf("no fond file:%s", fliepath) + err = fmt.Errorf("no found file:%s", fliepath) return } defer file.Close() From 541ffb0d4231c9fda078f3ebefdbfc6533c85583 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Thu, 30 Jun 2022 15:24:32 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=A1=E6=B6=88?= =?UTF-8?q?=E8=80=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 14 +++++++------- modules/hero/module.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 7b1e5e420..b78464f11 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -119,14 +119,14 @@ func (this *ModelHero) getOneHero(uid, heroId string) *pb.DBHero { } //消耗一张英雄卡 -func (this *ModelHero) consumeOneHeroCard(hero *pb.DBHero, count int32) error { - if hero == nil { - return fmt.Errorf("hero no exist") +func (this *ModelHero) consumeOneHeroCard(uid, heroId string, count int32) (err error) { + for i := 0; i < int(count); i++ { + if err := this.moduleHero.modelHero.DelListlds(uid, heroId); err != nil { + log.Errorf("%v", err) + break + } } - if hero.SameCount < count { - return fmt.Errorf("card no enough") - } - return this.moduleHero.modelHero.DelListlds(hero.Uid, hero.Id) + return } //更新英雄数据 diff --git a/modules/hero/module.go b/modules/hero/module.go index 9e033c60b..b0650a012 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -58,7 +58,7 @@ func (this *Hero) ChangeCard(uId string, heroCfgId int32, count int32) (code pb. } for _, v := range curList { - err := this.modelHero.consumeOneHeroCard(v, count) + err := this.modelHero.consumeOneHeroCard(v.Uid, v.Id, count) if err != nil { return pb.ErrorCode_DBError } From 22457148d8b640c70f891a77d6496bb6c357ecad Mon Sep 17 00:00:00 2001 From: zhaocy Date: Thu, 30 Jun 2022 15:24:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E9=87=91=E5=B8=81=E5=92=8C=E5=8D=A1=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/hero.go | 7 ++++--- cmd/robot/robot.go | 41 +++++++++++++++++++------------------- cmd/robot/user.go | 5 +++-- go.mod | 1 + go.sum | 1 + modules/user/api_create.go | 17 +++++++++++----- modules/user/module.go | 2 ++ utils/strings.go | 24 ++++++++++++++++++++++ 8 files changed, 68 insertions(+), 30 deletions(-) diff --git a/cmd/robot/hero.go b/cmd/robot/hero.go index 0df8b2e32..862e42948 100644 --- a/cmd/robot/hero.go +++ b/cmd/robot/hero.go @@ -13,6 +13,7 @@ var ( //hero heroBuilders = []*builder{ { + desc: "英雄列表", mainType: string(comm.ModuleHero), subType: hero.HeroSubTypeList, req: &pb.HeroListReq{}, @@ -23,7 +24,7 @@ var ( fmt.Printf("%d- %v\n", (i + 1), v) } }, - // enabled: true, + enabled: true, }, { mainType: string(comm.ModuleHero), subType: hero.HeroSubTypeInfo, @@ -61,8 +62,8 @@ var ( ExpCardID: "62bd0b4eca37634b8230d4be", Amount: 1, }, - rsp: &pb.HeroStrengthenUplvResp{}, - enabled: true, + rsp: &pb.HeroStrengthenUplvResp{}, + // enabled: true, }, } ) diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 2cd33221a..d3a9d073e 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -68,6 +68,7 @@ func (r *Robot) Run() { } type builder struct { + desc string mainType string subType string req proto.Message @@ -90,6 +91,7 @@ func (r *Robot) addBuilders(builders []*builder) { func (r *Robot) handleReq() { for _, b := range r.builders { if b.req != nil && !b.requested { + time.Sleep(time.Second * 1) b.requested = true b.start = time.Now() head := &pb.UserMessage{MainType: b.mainType, SubType: b.subType} @@ -113,7 +115,7 @@ func (r *Robot) handleRsp(msg *pb.UserMessage) { if b.print == nil { printReply(msg, b) } else { - fmt.Printf("===== rsp [%s.%s] =====\n", msg.MainType, msg.SubType) + fmt.Printf("===== %s [%s.%s] =====\n", b.desc, msg.MainType, msg.SubType) b.print(b.rsp) fmt.Println("==============================") } @@ -159,15 +161,14 @@ func (r *Robot) onUserLoaded() { r.RunNotify() //user r.RunUser() - + //hero + r.RunHero() //friend // r.RunFriend() //pack // r.RunPack() - //hero - r.RunHero() } //注册账号 @@ -198,21 +199,21 @@ func (r *Robot) AccountRegister(account string, sid int32) { fmt.Printf("account:%s 注册成功", regRsp.Account) //登录 - loginReg := &pb.UserLoginReq{ - Account: account, - Sid: sid, + var user_builders = []*builder{ + { + desc: "登录", + mainType: "user", + subType: "login", + req: &pb.UserLoginReq{ + Account: account, + Sid: sid, + }, + rsp: &pb.UserLoginResp{}, + enabled: true, + }, } - - head := &pb.UserMessage{ - MainType: "user", - SubType: "login", - Sec: r.BuildSecStr(), - } - err = r.SendToClient(head, loginReg) - if err != nil { - log.Fatal(err) - } - + r.addBuilders(user_builders) + r.handleReq() } } @@ -225,9 +226,9 @@ func printReply(msg *pb.UserMessage, builder *builder) { } else { tt = time.Since(builder.start) } - log.Printf("rsp [%v] [%s.%s] [%v:%v]", tt, m.ReqMainType, m.ReqSubType, int32(m.Code), m.Data) + log.Printf("rsp %s [%v] [%s.%s] [%v:%v]", builder.desc, tt, m.ReqMainType, m.ReqSubType, int32(m.Code), m.Data) } else { - log.Printf("rsp [%v] [%s.%s] [%v]", time.Since(builder.start), msg.MainType, msg.SubType, builder.rsp) + log.Printf("rsp %s [%v] [%s.%s] [%v]", builder.desc, time.Since(builder.start), msg.MainType, msg.SubType, builder.rsp) } } diff --git a/cmd/robot/user.go b/cmd/robot/user.go index 35a00148e..d50ed2fad 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -10,13 +10,14 @@ import ( var user_builders = []*builder{ { //create + desc: "创角", mainType: string(comm.ModuleUser), subType: user.UserSubTypeCreate, req: &pb.UserCreateReq{ //设置请求参数 NickName: "乐谷6301", }, - rsp: &pb.UserCreateRsp{}, - // enabled: true, + rsp: &pb.UserCreateRsp{}, + enabled: true, }, } diff --git a/go.mod b/go.mod index b1b0e2fe1..b9f0933ba 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,7 @@ require ( github.com/rs/xid v1.3.0 github.com/satori/go.uuid v1.2.0 github.com/smallnest/rpcx v1.7.4 + github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.2.1 github.com/spf13/pflag v1.0.5 github.com/tidwall/gjson v1.14.1 diff --git a/go.sum b/go.sum index ed2f49db8..7d40d401e 100644 --- a/go.sum +++ b/go.sum @@ -623,6 +623,7 @@ github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 73ab8f5b8..f05962790 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -41,6 +41,11 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa "name": req.NickName, } + //设置初始金币 + if val := this.module.configure.GetGlobalConf("init_gold"); val != "" { + update["gold"] = val + } + err := this.module.modelUser.Change(session.GetUserId(), update) if err != nil { code = pb.ErrorCode_DBError @@ -48,11 +53,13 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa } //初始化英雄卡 - defaultHero := []int32{15001, 25001} //TODO 从配置中读取 - err = this.hero.CreateHero(session.GetUserId(), defaultHero...) - if err != nil { - code = pb.ErrorCode_HeroInitCreat - return + if val := this.module.configure.GetGlobalConf("init_hero"); val != "" { + defaultHero := utils.TrInt32(val) + err = this.hero.CreateHero(session.GetUserId(), defaultHero...) + if err != nil { + code = pb.ErrorCode_HeroInitCreat + return + } } return diff --git a/modules/user/module.go b/modules/user/module.go index 0aa16c2cc..eb61bf57e 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -18,6 +18,7 @@ type User struct { api *apiComp modelUser *ModelUser modelSession *ModelSession + configure *configureComp } func (this *User) GetType() core.M_Modules { @@ -35,6 +36,7 @@ func (this *User) OnInstallComp() { this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser) this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession) + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } //获取英雄列表 diff --git a/utils/strings.go b/utils/strings.go index c153704d4..a3b27cae1 100644 --- a/utils/strings.go +++ b/utils/strings.go @@ -1,9 +1,12 @@ package utils import ( + "strconv" "strings" "go_dreamfactory/lego/sys/log" + + "github.com/spf13/cast" ) func ParseP(p string) (string, string, bool) { @@ -34,3 +37,24 @@ func DeleteString(list []string, ele string) []string { } return result } + +//转换包含数字字符串数组 +//eg. "3,4,5" to []int32{3,4,5} +func TrInt32(val string) (nums []int32) { + strArr := strings.Split(val, ",") + if len(strArr) == 0 { + return + } + + for _, n := range strArr { + if IsNum(strings.TrimSpace(n)) { + nums = append(nums, cast.ToInt32(strings.TrimSpace(n))) + } + } + return +} + +func IsNum(s string) bool { + _, err := strconv.ParseFloat(s, 64) + return err == nil +} From 0742fa1e89c863ffc725c670645d4f49c2465621 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 30 Jun 2022 16:13:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gateway/agent.go | 11 ++++++++--- modules/items/api_getlist.go | 2 +- modules/items/api_sellItem.go | 2 +- modules/items/api_useItem.go | 2 +- sys/cache/cache.go | 15 +++++++++++---- sys/cache/options.go | 12 ++++++++++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 69e32f76d..a6a266b8e 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -81,7 +81,7 @@ locp: break locp } } else { - data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode_SecKeyInvalid}) + data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode_SecKeyInvalid, Message: err.Error()}) if err = this.WriteMsg(&pb.UserMessage{ MainType: comm.MainTypeNotify, SubType: comm.SubTypeErrorNotify, @@ -127,11 +127,11 @@ func (this *Agent) secAuth(msg *pb.UserMessage) error { if !utils.ValidSecretKey(msg.Sec) { //验证失败 return fmt.Errorf("key invalid") } - return decodeUserData(msg) + return this.decodeUserData(msg) } //解码 -func decodeUserData(msg *pb.UserMessage) error { +func (this *Agent) decodeUserData(msg *pb.UserMessage) error { base64Str := msg.Sec dec, err := base64.StdEncoding.DecodeString(base64Str[35:]) if err != nil { @@ -159,6 +159,10 @@ func decodeUserData(msg *pb.UserMessage) error { return err } msg.Data = ad + } else { + if this.UserId() == "" { + return fmt.Errorf("no login") + } } return nil } @@ -211,6 +215,7 @@ func (this *Agent) Close() { func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { reply := &pb.RPCMessageReply{} log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) + servicePath := comm.Service_Worker if rule, ok := this.gateway.GetMsgDistribute(msg.MainType, msg.SubType); ok { servicePath = rule diff --git a/modules/items/api_getlist.go b/modules/items/api_getlist.go index 1258feaa8..059f7a8ce 100644 --- a/modules/items/api_getlist.go +++ b/modules/items/api_getlist.go @@ -25,7 +25,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, agrs map[string]interfac dels []string ) defer func() { - session.SendMsg(string(this.module.GetType()), GetlistResp, &pb.ItemsGetlistResp{Grids: grids}) + session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: grids}) if code == pb.ErrorCode_Success { go func() { //异步处理修改数据 this.module.modelItems.Pack_UpdateUserPack(session.GetUserId(), modifys...) diff --git a/modules/items/api_sellItem.go b/modules/items/api_sellItem.go index 5a2448761..c3b0b6732 100644 --- a/modules/items/api_sellItem.go +++ b/modules/items/api_sellItem.go @@ -14,7 +14,7 @@ func (this *apiComp) SellItemCheck(session comm.IUserSession, req *pb.ItemsSellI //出售道具 func (this *apiComp) SellItem(session comm.IUserSession, agrs map[string]interface{}, req *pb.ItemsSellItemReq) (code pb.ErrorCode) { defer func() { - session.SendMsg(string(this.module.GetType()), SellItemResp, &pb.ItemsSellItemResp{}) + session.SendMsg(string(this.module.GetType()), "sellitem", &pb.ItemsSellItemResp{}) }() return } diff --git a/modules/items/api_useItem.go b/modules/items/api_useItem.go index 8f4cb64a0..89f50b237 100644 --- a/modules/items/api_useItem.go +++ b/modules/items/api_useItem.go @@ -14,7 +14,7 @@ func (this *apiComp) UseitemCheck(session comm.IUserSession, req *pb.ItemsUseIte //使用道具 func (this *apiComp) Useitem(session comm.IUserSession, agrs map[string]interface{}, req *pb.ItemsUseItemReq) (code pb.ErrorCode) { defer func() { - session.SendMsg(string(this.module.GetType()), UseItemResp, &pb.ItemsUseItemResp{}) + session.SendMsg(string(this.module.GetType()), "useitem", &pb.ItemsUseItemResp{}) }() return diff --git a/sys/cache/cache.go b/sys/cache/cache.go index 924bbaa54..b7d2476ae 100644 --- a/sys/cache/cache.go +++ b/sys/cache/cache.go @@ -19,10 +19,17 @@ type Cache struct { //初始化 redis 对象 func (this *Cache) init() (err error) { - this.redis, err = redis.NewSys( - redis.SetRedisType(redis.Redis_Cluster), - redis.SetRedis_Cluster_Addr(this.options.Redis_Addr), - redis.SetRedis_Cluster_Password(this.options.Redis_Password)) + if this.options.Redis_IsCluster { + this.redis, err = redis.NewSys( + redis.SetRedisType(redis.Redis_Cluster), + redis.SetRedis_Cluster_Addr(this.options.Redis_Addr), + redis.SetRedis_Cluster_Password(this.options.Redis_Password)) + } else { + this.redis, err = redis.NewSys( + redis.SetRedisType(redis.Redis_Single), + redis.SetRedis_Single_Addr(this.options.Redis_Addr[0]), + redis.SetRedis_Single_Password(this.options.Redis_Password)) + } return } diff --git a/sys/cache/options.go b/sys/cache/options.go index aa940d657..921448905 100644 --- a/sys/cache/options.go +++ b/sys/cache/options.go @@ -11,8 +11,16 @@ import ( */ type Option func(*Options) type Options struct { - Redis_Addr []string //redis 的集群地址 - Redis_Password string //redis的密码 + Redis_IsCluster bool //是否是集群 + Redis_Addr []string //redis 的集群地址 + Redis_Password string //redis的密码 +} + +//设置系统的集群地址 +func Set_Redis_IsCluster(v bool) Option { + return func(o *Options) { + o.Redis_IsCluster = v + } } //设置系统的集群地址