// Copyright 2020 Google LLC All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. syntax = "proto3"; package agones.dev.sdk.alpha; option go_package = "./alpha"; import "google/api/annotations.proto"; import "protoc-gen-openapiv2/options/annotations.proto"; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { info: { title: "alpha.proto"; version: "version not set"; }; schemes: HTTP; consumes: "application/json"; produces: "application/json"; }; // SDK service to be used in the GameServer SDK to the Pod Sidecar. service SDK { // PlayerConnect increases the SDK’s stored player count by one, and appends this playerID to GameServer.Status.Players.IDs. // // GameServer.Status.Players.Count and GameServer.Status.Players.IDs are then set to update 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 this playerID was not already in the // list of connected playerIDs. // // If the playerID 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. // // Warning: Do not use this method if you are manually managing GameServer.Status.Players.IDs and GameServer.Status.Players.Count // through the Kubernetes API, as indeterminate results will occur. rpc PlayerConnect (PlayerID) returns (Bool) { option (google.api.http) = { post: "/alpha/player/connect" body: "*" }; } // Decreases the SDK’s stored player count by one, and removes the playerID from GameServer.Status.Players.IDs. // // GameServer.Status.Players.Count and GameServer.Status.Players.IDs are then set to update 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. // // Warning: Do not use this method if you are manually managing GameServer.status.players.IDs and GameServer.status.players.Count // through the Kubernetes API, as indeterminate results will occur. rpc PlayerDisconnect (PlayerID) returns (Bool) { option (google.api.http) = { post: "/alpha/player/disconnect" body: "*" }; } // Update the GameServer.Status.Players.Capacity value with a new capacity. rpc SetPlayerCapacity (Count) returns (Empty) { option (google.api.http) = { put: "/alpha/player/capacity" body: "*" }; } // Retrieves the current player capacity. This is always accurate from what has been set through this SDK, // even if the value has yet to be updated on the GameServer status resource. // // If GameServer.Status.Players.Capacity is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. rpc GetPlayerCapacity (Empty) returns (Count) { option (google.api.http) = { get: "/alpha/player/capacity" }; } // Retrieves the current player count. This is always accurate from what has been set through this SDK, // even if the value has yet to be updated on the GameServer status resource. // // If GameServer.Status.Players.Count is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. 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 from what has been set through this SDK, // even if the value has yet to be updated on the GameServer status resource. // // If GameServer.Status.Players.IDs is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to determine connected status. 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 from what has been set through this SDK, // even if the value has yet to be updated on the GameServer status resource. // // If GameServer.Status.Players.IDs is set manually through the Kubernetes API, use SDK.GameServer() or SDK.WatchGameServer() instead to view this value. rpc GetConnectedPlayers(Empty) returns (PlayerIDList) { option (google.api.http) = { get: "/alpha/player/connected" }; } } // I am Empty message Empty { } // Store a count variable. message Count { int64 count = 1; } // Store a boolean result message Bool { bool bool = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {format: "boolean"}]; } // The unique identifier for a given player. message PlayerID { string playerID = 1; } // List of Player IDs message PlayerIDList { repeated string list = 1; }