-
Notifications
You must be signed in to change notification settings - Fork 2
/
tic_tac_toe.proto
70 lines (57 loc) · 1.32 KB
/
tic_tac_toe.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
syntax = "proto3";
package nl.toefel.grpc.game;
service TicTacToe {
rpc TestConnection (TestConnectionRequest) returns (TestConnectionResponse) { }
rpc CreatePlayer (CreatePlayerRequest) returns (Player) { }
rpc ListPlayers (ListPlayersRequest) returns (ListPlayersResponse) { }
rpc PlayGame (stream GameCommand) returns (stream GameEvent) { }
}
message TestConnectionRequest {}
message TestConnectionResponse {}
message CreatePlayerRequest {
string name = 1;
}
message Player {
string id = 1;
string name = 2;
int64 join_timestamp = 3;
int32 wins = 4;
}
message ListPlayersRequest { }
message ListPlayersResponse {
repeated Player players = 1;
}
message GameCommand {
oneof command {
StartGame start_game = 2;
BoardMove board_move = 4;
}
}
message StartGame {
Player from_player = 2;
Player to_player = 3;
}
message BoardMove {
string game_id = 1;
int32 row = 2;
int32 column = 3;
}
message GameEvent {
EventType type = 1;
string game_id = 2;
Player player_x = 3;
Player player_o = 4;
Player next_player = 5;
Board board = 6;
}
enum EventType {
START_GAME = 0;
BOARD_MOVE = 1;
OTHER_PLAYER_LEFT = 2;
}
message Board {
repeated BoardRow rows = 1;
}
message BoardRow {
repeated string columns = 1;
}