Commit
8c6dec4572d3c2835209d5f44e6ef7d772af48d0
0 parents
first commit
| |
1
| +++ a/README.md |
| @@ -0,0 +1,13 @@ |
| @@ -0,0 +1,13 @@ |
| |
1
| + |
| |
2
| +## pro2dProtobuffer |
| |
3
| +pro2d 服务器客户端共享的protobuffer |
| |
4
| + |
| |
5
| +## Usage |
| |
6
| +### golang |
| |
7
| +生成golang文件 |
| |
8
| +``` |
| |
9
| +$ chmod +x generate.sh && ./generate.sh |
| |
10
| +``` |
| |
11
| + |
| |
12
| +### C# |
| |
13
| +生成C#文件 |
0
| \ No newline at end of file |
14
| \ No newline at end of file |
| |
1
| +++ a/account.proto |
| @@ -0,0 +1,34 @@ |
| @@ -0,0 +1,34 @@ |
| |
1
| +syntax = "proto3"; |
| |
2
| +option go_package = "./pb;pb"; |
| |
3
| + |
| |
4
| +package account; |
| |
5
| +import "public.proto"; |
| |
6
| + |
| |
7
| +message ServiceInfo { |
| |
8
| + string id = 1; |
| |
9
| + string name = 2; |
| |
10
| + string address = 3; |
| |
11
| +} |
| |
12
| + |
| |
13
| +message AccountInfo{ |
| |
14
| + string phone = 2; |
| |
15
| + string password = 3; |
| |
16
| + int64 uid = 4; |
| |
17
| + string device = 5; |
| |
18
| +} |
| |
19
| + |
| |
20
| +message CreateTokenRsp { |
| |
21
| + string token = 1; |
| |
22
| + ServiceInfo game_service = 2; |
| |
23
| +} |
| |
24
| + |
| |
25
| +message Register { |
| |
26
| + string phone = 1; |
| |
27
| + string password = 2; |
| |
28
| + int32 code = 3; |
| |
29
| +} |
| |
30
| + |
| |
31
| +service Account{ |
| |
32
| + rpc RegisterHandler(Register) returns (public.PubRsp) {} |
| |
33
| + rpc CreateTokenHandler(AccountInfo) returns (CreateTokenRsp) {} |
| |
34
| +} |
0
| \ No newline at end of file |
35
| \ No newline at end of file |
| |
1
| +++ a/game.proto |
| @@ -0,0 +1,28 @@ |
| @@ -0,0 +1,28 @@ |
| |
1
| +syntax = "proto3"; |
| |
2
| +option go_package = "./pb;pb"; |
| |
3
| + |
| |
4
| +package game; |
| |
5
| +import "public.proto"; |
| |
6
| + |
| |
7
| +message Role{ |
| |
8
| + string id = 1; |
| |
9
| + int32 level = 3; |
| |
10
| + int64 login_time = 4; |
| |
11
| + string device = 5; |
| |
12
| + int64 uid = 6; |
| |
13
| +} |
| |
14
| + |
| |
15
| +message Token { |
| |
16
| + string token = 1; |
| |
17
| +} |
| |
18
| + |
| |
19
| +message RoleRsp { |
| |
20
| + public.PubRsp rsp = 1; |
| |
21
| + Role role = 2; |
| |
22
| +} |
| |
23
| + |
| |
24
| +service Game{ |
| |
25
| + rpc HeartBeatHandler(Token) returns (public.PubRsp) {} |
| |
26
| + rpc LoginHandler(Token) returns (RoleRsp) {} |
| |
27
| + rpc CreateRoleHandler(Token) returns (RoleRsp) {} |
| |
28
| +} |
0
| \ No newline at end of file |
29
| \ No newline at end of file |
| |
1
| +++ a/generate.sh |
| @@ -0,0 +1,2 @@ |
| @@ -0,0 +1,2 @@ |
| |
1
| +#!/bin/bash |
| |
2
| +protoc -I. --go_out=. --go-grpc_out=. ./*proto |
| |
1
| +++ a/public.proto |
| @@ -0,0 +1,13 @@ |
| @@ -0,0 +1,13 @@ |
| |
1
| +syntax = "proto3"; |
| |
2
| +package public; |
| |
3
| + |
| |
4
| +option go_package = "./pb;pb"; |
| |
5
| + |
| |
6
| +message PubRsp { |
| |
7
| + int32 code = 1; |
| |
8
| + string msg = 2; |
| |
9
| +} |
| |
10
| + |
| |
11
| +message GenerateToken { |
| |
12
| + string phone = 1; |
| |
13
| +} |
0
| \ No newline at end of file |
14
| \ No newline at end of file |