Commit a75664632cf6508823d5f9712d5c493e0b7a1038

Authored by zhangqijia
1 parent de33a3c4

fix: update protocode

cmd/gameserver/plugin/plugin.go
... ... @@ -16,7 +16,7 @@ func init() {
16 16 func GetActionMap() map[interface{}]interface{} {
17 17 logger.Debug("init protocode...")
18 18 am := make(map[interface{}]interface{})
19   - am[uint32(pb.ProtoCode_LoginReq)] = LoginRpc
  19 + am[uint32(pb.ProtoCode_LoginRsp)] = LoginRpc
20 20  
21 21 return am
22 22 }
... ...
cmd/gameserver/service/agent.go
... ... @@ -112,12 +112,12 @@ func (c *Agent) OnMessage(msg components.IMessage) error {
112 112 atomic.StoreInt64(&c.lastHeartCheckTime, common.Timex())
113 113 logger.Debug("req protocolID: %d, %s", msg.GetHeader().GetMsgID(), msg.GetData())
114 114 //heart
115   - if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_HeartReq) {
  115 + if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_HeartRpc) {
116 116 return nil
117 117 }
118 118  
119 119 //login
120   - if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_LoginReq) {
  120 + if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_LoginRpc) {
121 121 code, protoMsg := c.OnLoginQuery(msg)
122 122 return c.SendMsg(code, msg.GetHeader().GetMsgID(), protoMsg)
123 123 }
... ... @@ -128,7 +128,7 @@ func (c *Agent) OnMessage(msg components.IMessage) error {
128 128 return fmt.Errorf("cmd: %d, handler is nil", msg.GetHeader().GetMsgID())
129 129 }
130 130  
131   - if msg.GetHeader().GetMsgID() != uint32(pb.ProtoCode_CreateReq) && c.Role == nil {
  131 + if msg.GetHeader().GetMsgID() != uint32(pb.ProtoCode_CreateRpc) && c.Role == nil {
132 132 return c.Send(-101, msg.GetHeader().GetMsgID(), nil)
133 133 }
134 134  
... ...
cmd/test/action/protocode.go
... ... @@ -6,7 +6,6 @@ import (
6 6  
7 7 func GetTestActionMap() map[interface{}]interface{} {
8 8 am := make(map[interface{}]interface{})
9   - am[uint32(pb.ProtoCode_LoginRsp)] = LoginRsp
10 9 am[uint32(pb.ProtoCode_HeartRpc)] = HeartRsp
11 10 am[uint32(pb.ProtoCode_CreateRpc)] = CreateRsp
12 11 am[uint32(pb.ProtoCode_ChangeTeamRpc)] = ChangeTeamRsp
... ...
cmd/test/main.go
... ... @@ -26,7 +26,7 @@ func main() {
26 26 time.Sleep(2 * time.Second)
27 27 for {
28 28 //tc.SendPB(pb.ProtoCode_HeartReq, nil)
29   - tc.SendPB(pb.ProtoCode_HeroUpLevelReq, pp)
  29 + tc.SendPB(pb.ProtoCode_HeroUpLevelRpc, pp)
30 30 time.Sleep(5 * time.Second)
31 31 }
32 32  
... ...
pb/protocode.pb.go
... ... @@ -24,8 +24,8 @@ type ProtoCode int32
24 24  
25 25 const (
26 26 ProtoCode_UNKNOWN ProtoCode = 0
27   - ProtoCode_LoginRsp ProtoCode = 1
28   - ProtoCode_HeartRpc ProtoCode = 2
  27 + ProtoCode_HeartRpc ProtoCode = 1
  28 + ProtoCode_LoginRpc ProtoCode = 2
29 29 ProtoCode_CreateRpc ProtoCode = 3
30 30 ProtoCode_ChangeTeamRpc ProtoCode = 4
31 31 ProtoCode_HeroEquipReferRpc ProtoCode = 5
... ... @@ -48,8 +48,8 @@ const (
48 48 var (
49 49 ProtoCode_name = map[int32]string{
50 50 0: "UNKNOWN",
51   - 1: "LoginRsp",
52   - 2: "HeartRpc",
  51 + 1: "HeartRpc",
  52 + 2: "LoginRpc",
53 53 3: "CreateRpc",
54 54 4: "ChangeTeamRpc",
55 55 5: "HeroEquipReferRpc",
... ... @@ -69,8 +69,8 @@ var (
69 69 }
70 70 ProtoCode_value = map[string]int32{
71 71 "UNKNOWN": 0,
72   - "LoginRsp": 1,
73   - "HeartRpc": 2,
  72 + "HeartRpc": 1,
  73 + "LoginRpc": 2,
74 74 "CreateRpc": 3,
75 75 "ChangeTeamRpc": 4,
76 76 "HeroEquipReferRpc": 5,
... ... @@ -123,8 +123,8 @@ var file_protocode_proto_rawDesc = []byte{
123 123 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
124 124 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xfb, 0x02, 0x0a,
125 125 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e,
126   - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
127   - 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x70,
  126 + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74,
  127 + 0x52, 0x70, 0x63, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x70,
128 128 0x63, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x70, 0x63,
129 129 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d,
130 130 0x52, 0x70, 0x63, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x48, 0x65, 0x72, 0x6f, 0x45, 0x71, 0x75,
... ...
tools/generator.py
... ... @@ -28,6 +28,9 @@ def generatorProto(path):
28 28 GoCodeData = ""
29 29 GoCodeTestData = ""
30 30 for file in files:
  31 + if file.find("account.proto") != -1:
  32 + continue
  33 +
31 34 if os.path.isdir(file):
32 35 continue
33 36  
... ... @@ -47,12 +50,12 @@ def generatorProto(path):
47 50 messageStr = sline[1].replace('\n', '').replace('{', "")
48 51 n1 = messageStr.find('Req')
49 52 loginReq = messageStr.find('LoginReq')
50   - if loginReq != -1:
51   - continue
52 53  
53 54 if n1 != -1:
54 55 code += 1
55 56 ProtoCodeData += ProtoCodeLineReq.format(messageStr[:n1], code)
  57 + if loginReq != -1:
  58 + continue
56 59 GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1])
57 60 GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1])
58 61  
... ... @@ -67,12 +70,12 @@ def generatorProto(path):
67 70 messageStr = sline[1].replace('\n', '').replace('{', "")
68 71 n2 = messageStr.find('Rsp')
69 72 loginReq = messageStr.find('LoginReq')
70   - if loginReq != -1:
71   - continue
72 73  
73 74 if n2 != -1:
74 75 code += 1
75 76 ProtoCodeData += ProtoCodeLineRsp.format(messageStr[:n2], code)
  77 + if loginReq != -1:
  78 + continue
76 79 GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2])
77 80  
78 81  
... ...