Skip to content

Commit

Permalink
Changes in proto for Player Tracking design update
Browse files Browse the repository at this point in the history
This includes changes to make PlayerID consistent in casing.

Code generation will come in the next PR to make things easier to
review.

Work on #1033
  • Loading branch information
markmandel committed Apr 18, 2020
1 parent c96f551 commit e791c21
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
64 changes: 53 additions & 11 deletions proto/sdk/alpha/alpha.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,76 @@ import "google/api/annotations.proto";

// SDK service to be used in the GameServer SDK to the Pod Sidecar.
service SDK {
// Call when a player has connected.
rpc PlayerConnect (PlayerId) returns (Empty) {
// PlayerConnect increases the SDK’s stored player count by one, and appends this playerID to status.players.id.
// status.players.count and status.players.ids is then set to update to the player count and id list a second from now, unless there is already an update pending, in which case the update joins that batch operation.
//
// PlayerConnect returns true and adds the playerID to the list of playerIDs if the playerIDs was not already in the
// list of connected playerIDs.
//
// If the player exists within the list of connected playerIDs, PlayerConnect will return false, and the list of
// connected playerIDs will be left unchanged.
//
// An error will be returned if the playerID was not already in the list of connected playerIDs but the player capacity for
// the server has been reached. The playerID will not be added to the list of playerIDs.
rpc PlayerConnect (PlayerID) returns (Bool) {
option (google.api.http) = {
post: "/alpha/player/connect"
body: "*"
};
}

// Call when a player has disconnected.
rpc PlayerDisconnect (PlayerId) returns (Empty) {
// Decreases the SDK’s stored player count by one, and removes the playerID from status.players.id
//
// status.players.count and status.players.ids is then set to update to the player count and id list a second from now, unless there is already an update pending, in which case the update joins that batch operation.
//
// PlayerDisconnect will return true and remove the supplied playerID from the list of connected playerIDs if the
// playerID value exists within the list.
//
// If the playerID was not in the list of connected playerIDs, the call will return false, and the connected playerID list
// will be left unchanged.
rpc PlayerDisconnect (PlayerID) returns (Bool) {
option (google.api.http) = {
post: "/alpha/player/disconnect"
body: "*"
};
}

// Change the player capacity to a new value.
// Update the status.capacity value with a new capacity.
rpc SetPlayerCapacity (Count) returns (Empty) {
option (google.api.http) = {
post: "/alpha/player/capacity"
body: "*"
};
}

// Get the last player capacity that was set through the SDK.
// Retrieves the current capacity. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.
// If the player capacity is set from outside the SDK, use SDK.GameServer() instead.
rpc GetPlayerCapacity(Empty) returns (Count) {
rpc GetPlayerCapacity (Empty) returns (Count) {
option (google.api.http) = {
get: "/alpha/player/capacity"
};
}

// get the current player count
rpc GetPlayerCount(Empty) returns (Count) {
// Retrieves the current player count. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.
rpc GetPlayerCount (Empty) returns (Count) {
option (google.api.http) = {
get: "/alpha/player/count"
};
}

// Returns if the playerID is currently connected to the GameServer. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.
rpc IsPlayerConnected (PlayerID) returns (Bool) {
option (google.api.http) = {
get: "/alpha/player/connected/{playerID}"
};
}

// Returns the list of the currently connected player ids. This is always accurate, even if the value hasn’t been updated to the GameServer status yet.
rpc GetConnectedPlayers(Empty) returns (PlayerIDList) {
option (google.api.http) = {
get: "/alpha/player/connected"
};
}
}

// I am Empty
Expand All @@ -70,7 +102,17 @@ message Count {
int64 count = 1;
}

// Store a boolean result
message Bool {
bool bool = 1;
}

// The unique identifier for a given player.
message PlayerId {
string playerId = 1;
message PlayerID {
string playerID = 1;
}

// List of Player IDs
message PlayerIDList {
repeated string list = 1;
}
1 change: 1 addition & 0 deletions proto/sdk/sdk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ message GameServer {
message PlayerStatus {
int64 count = 1;
int64 capacity = 2;
repeated string IDs = 3;
}

string state = 1;
Expand Down

0 comments on commit e791c21

Please sign in to comment.