Commit a75664632cf6508823d5f9712d5c493e0b7a1038

Authored by zhangqijia
1 parent de33a3c4

fix: update protocode

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