diff --git a/build/build-sdk-images/rust/gen.sh b/build/build-sdk-images/rust/gen.sh index f2a9d3fbad..c7b674f214 100644 --- a/build/build-sdk-images/rust/gen.sh +++ b/build/build-sdk-images/rust/gen.sh @@ -24,9 +24,17 @@ cd /go/src/agones.dev/agones protoc \ -I ${googleapis} -I ${sdk} sdk.proto \ --rust_out=sdks/rust/src/grpc --grpc_out=sdks/rust/src/grpc \ - --plugin=protoc-gen-grpc=`which grpc_rust_plugin` \ + --plugin=protoc-gen-grpc=`which grpc_rust_plugin` +protoc \ + -I ${googleapis} -I ${sdk}/alpha alpha.proto \ + --rust_out=sdks/rust/src/grpc --grpc_out=sdks/rust/src/grpc \ + --plugin=protoc-gen-grpc=`which grpc_rust_plugin` cat ./build/boilerplate.go.txt ./sdks/rust/src/grpc/sdk.rs >> ./sdk.rs cat ./build/boilerplate.go.txt ./sdks/rust/src/grpc/sdk_grpc.rs >> ./sdk_grpc.rs +cat ./build/boilerplate.go.txt ./sdks/rust/src/grpc/alpha.rs >> ./alpha.rs +cat ./build/boilerplate.go.txt ./sdks/rust/src/grpc/alpha_grpc.rs >> ./alpha_grpc.rs mv ./sdk.rs ./sdks/rust/src/grpc/ -mv ./sdk_grpc.rs ./sdks/rust/src/grpc/ \ No newline at end of file +mv ./sdk_grpc.rs ./sdks/rust/src/grpc/ +mv ./alpha.rs ./sdks/rust/src/grpc/ +mv ./alpha_grpc.rs ./sdks/rust/src/grpc/ diff --git a/build/includes/sdk.mk b/build/includes/sdk.mk index 95d31005e2..b26215b4b6 100644 --- a/build/includes/sdk.mk +++ b/build/includes/sdk.mk @@ -165,7 +165,10 @@ run-sdk-conformance-test-go: $(MAKE) run-sdk-conformance-no-build SDK_FOLDER=go GRPC_PORT=9001 HTTP_PORT=9101 FEATURE_GATES=PlayerTracking=true TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(ALPHA_CONFORMANCE_TESTS) run-sdk-conformance-test-rust: - $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust + # run without feature flags + $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 + # run with feature flags enabled + $(MAKE) run-sdk-conformance-test SDK_FOLDER=rust GRPC_PORT=9004 HTTP_PORT=9104 FEATURE_GATES=PlayerTracking=true TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(ALPHA_CONFORMANCE_TESTS) run-sdk-conformance-test-rest: # run without feature flags diff --git a/sdks/rust/src/alpha.rs b/sdks/rust/src/alpha.rs new file mode 100644 index 0000000000..af9c68fd36 --- /dev/null +++ b/sdks/rust/src/alpha.rs @@ -0,0 +1,114 @@ +// 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. + +use std::sync::Arc; + +use grpcio; + +use errors::*; +use grpc::alpha; +use grpc::alpha_grpc; + +/// Alpha is an instance of the Agones Alpha SDK +pub struct Alpha { + client: Arc, +} + +impl Alpha { + /// new creates a new instance of the Alpha SDK + pub fn new(ch: grpcio::Channel) -> Alpha { + let cli = alpha_grpc::SdkClient::new(ch); + Alpha { + client: Arc::new(cli), + } + } + + /// This returns the last player capacity that was set through the SDK. + /// If the player capacity is set from outside the SDK, use sdk.get_gameserver() instead. + pub fn get_player_capacity(&self) -> Result { + let req = alpha::Empty::new(); + let count = self.client.get_player_capacity(&req).map(|c| c.count)?; + Ok(count) + } + + /// This changes the player capacity to a new value. + pub fn set_player_capacity(&self, capacity: i64) -> Result<()> { + let mut c = alpha::Count::new(); + c.set_count(capacity); + let res = self.client.set_player_capacity(&c).map(|_| ())?; + Ok(res) + } + + /// This function increases the SDK’s stored player count by one, and appends this playerID to GameServer.status.players.ids. + /// Returns true and adds the playerID to the list of playerIDs if the playerIDs was not already in the list of connected playerIDs. + pub fn player_connect(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self.client.player_connect(&p).map(|b| b.bool)?; + Ok(res) + } + + /// This function decreases the SDK’s stored player count by one, and removes the playerID from GameServer.status.players.ids. + /// Will return true and remove the supplied playerID from the list of connected playerIDs if the playerID value exists within the list. + pub fn player_disconnect(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self.client.player_disconnect(&p).map(|b| b.bool)?; + Ok(res) + } + + /// Returns the current player count. + pub fn get_player_count(&self) -> Result { + let req = alpha::Empty::new(); + let count = self.client.get_player_count(&req).map(|c| c.count)?; + Ok(count) + } + + /// This 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. + pub fn is_player_connected(&self, id: S) -> Result + where + S: Into, + { + let mut p = alpha::PlayerID::new(); + p.set_playerID(id.into()); + let res = self.client.is_player_connected(&p).map(|b| b.bool)?; + Ok(res) + } + + /// This returns the list of the currently connected player ids. + /// This is always accurate, even if the value has not been updated to the Game Server status yet. + pub fn get_connected_players(&self) -> Result> { + let req = alpha::Empty::new(); + let res = self + .client + .get_connected_players(&req) + .map(|pl| pl.list.into())?; + Ok(res) + } +} + +impl Clone for Alpha { + fn clone(&self) -> Self { + Self { + client: Arc::clone(&self.client), + } + } +} diff --git a/sdks/rust/src/grpc/alpha.rs b/sdks/rust/src/grpc/alpha.rs new file mode 100644 index 0000000000..6c076f4ac7 --- /dev/null +++ b/sdks/rust/src/grpc/alpha.rs @@ -0,0 +1,974 @@ +// 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. + +// This code was autogenerated. Do not edit directly. +// This file is generated by rust-protobuf 2.0.2. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +use protobuf::Message as Message_imported_for_functions; +use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; + +#[derive(PartialEq,Clone,Default)] +pub struct Empty { + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +impl Empty { + pub fn new() -> Empty { + ::std::default::Default::default() + } +} + +impl ::protobuf::Message for Empty { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Empty { + Empty::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let fields = ::std::vec::Vec::new(); + ::protobuf::reflect::MessageDescriptor::new::( + "Empty", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Empty { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Empty, + }; + unsafe { + instance.get(Empty::new) + } + } +} + +impl ::protobuf::Clear for Empty { + fn clear(&mut self) { + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Empty { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Empty { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Count { + // message fields + pub count: i64, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +impl Count { + pub fn new() -> Count { + ::std::default::Default::default() + } + + // int64 count = 1; + + pub fn clear_count(&mut self) { + self.count = 0; + } + + // Param is passed by value, moved + pub fn set_count(&mut self, v: i64) { + self.count = v; + } + + pub fn get_count(&self) -> i64 { + self.count + } +} + +impl ::protobuf::Message for Count { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_int64()?; + self.count = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.count != 0 { + my_size += ::protobuf::rt::value_size(1, self.count, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.count != 0 { + os.write_int64(1, self.count)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Count { + Count::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeInt64>( + "count", + |m: &Count| { &m.count }, + |m: &mut Count| { &mut m.count }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Count", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Count { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Count, + }; + unsafe { + instance.get(Count::new) + } + } +} + +impl ::protobuf::Clear for Count { + fn clear(&mut self) { + self.clear_count(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Count { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Count { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Bool { + // message fields + pub bool: bool, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +impl Bool { + pub fn new() -> Bool { + ::std::default::Default::default() + } + + // bool bool = 1; + + pub fn clear_bool(&mut self) { + self.bool = false; + } + + // Param is passed by value, moved + pub fn set_bool(&mut self, v: bool) { + self.bool = v; + } + + pub fn get_bool(&self) -> bool { + self.bool + } +} + +impl ::protobuf::Message for Bool { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_bool()?; + self.bool = tmp; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if self.bool != false { + my_size += 2; + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if self.bool != false { + os.write_bool(1, self.bool)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Bool { + Bool::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "bool", + |m: &Bool| { &m.bool }, + |m: &mut Bool| { &mut m.bool }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "Bool", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static Bool { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const Bool, + }; + unsafe { + instance.get(Bool::new) + } + } +} + +impl ::protobuf::Clear for Bool { + fn clear(&mut self) { + self.clear_bool(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Bool { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Bool { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct PlayerID { + // message fields + pub playerID: ::std::string::String, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +impl PlayerID { + pub fn new() -> PlayerID { + ::std::default::Default::default() + } + + // string playerID = 1; + + pub fn clear_playerID(&mut self) { + self.playerID.clear(); + } + + // Param is passed by value, moved + pub fn set_playerID(&mut self, v: ::std::string::String) { + self.playerID = v; + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_playerID(&mut self) -> &mut ::std::string::String { + &mut self.playerID + } + + // Take field + pub fn take_playerID(&mut self) -> ::std::string::String { + ::std::mem::replace(&mut self.playerID, ::std::string::String::new()) + } + + pub fn get_playerID(&self) -> &str { + &self.playerID + } +} + +impl ::protobuf::Message for PlayerID { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.playerID)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if !self.playerID.is_empty() { + my_size += ::protobuf::rt::string_size(1, &self.playerID); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + if !self.playerID.is_empty() { + os.write_string(1, &self.playerID)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> PlayerID { + PlayerID::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "playerID", + |m: &PlayerID| { &m.playerID }, + |m: &mut PlayerID| { &mut m.playerID }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "PlayerID", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static PlayerID { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const PlayerID, + }; + unsafe { + instance.get(PlayerID::new) + } + } +} + +impl ::protobuf::Clear for PlayerID { + fn clear(&mut self) { + self.clear_playerID(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for PlayerID { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for PlayerID { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct PlayerIDList { + // message fields + pub list: ::protobuf::RepeatedField<::std::string::String>, + // special fields + unknown_fields: ::protobuf::UnknownFields, + cached_size: ::protobuf::CachedSize, +} + +impl PlayerIDList { + pub fn new() -> PlayerIDList { + ::std::default::Default::default() + } + + // repeated string list = 1; + + pub fn clear_list(&mut self) { + self.list.clear(); + } + + // Param is passed by value, moved + pub fn set_list(&mut self, v: ::protobuf::RepeatedField<::std::string::String>) { + self.list = v; + } + + // Mutable pointer to the field. + pub fn mut_list(&mut self) -> &mut ::protobuf::RepeatedField<::std::string::String> { + &mut self.list + } + + // Take field + pub fn take_list(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { + ::std::mem::replace(&mut self.list, ::protobuf::RepeatedField::new()) + } + + pub fn get_list(&self) -> &[::std::string::String] { + &self.list + } +} + +impl ::protobuf::Message for PlayerIDList { + fn is_initialized(&self) -> bool { + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + ::protobuf::rt::read_repeated_string_into(wire_type, is, &mut self.list)?; + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + for value in &self.list { + my_size += ::protobuf::rt::string_size(1, &value); + }; + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + for v in &self.list { + os.write_string(1, &v)?; + }; + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &::std::any::Any { + self as &::std::any::Any + } + fn as_any_mut(&mut self) -> &mut ::std::any::Any { + self as &mut ::std::any::Any + } + fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> PlayerIDList { + PlayerIDList::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, + }; + unsafe { + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "list", + |m: &PlayerIDList| { &m.list }, + |m: &mut PlayerIDList| { &mut m.list }, + )); + ::protobuf::reflect::MessageDescriptor::new::( + "PlayerIDList", + fields, + file_descriptor_proto() + ) + }) + } + } + + fn default_instance() -> &'static PlayerIDList { + static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const PlayerIDList, + }; + unsafe { + instance.get(PlayerIDList::new) + } + } +} + +impl ::protobuf::Clear for PlayerIDList { + fn clear(&mut self) { + self.clear_list(); + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for PlayerIDList { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for PlayerIDList { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { + ::protobuf::reflect::ProtobufValueRef::Message(self) + } +} + +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x0balpha.proto\x12\x14agones.dev.sdk.alpha\x1a\x1cgoogle/api/annotati\ + ons.proto\"\x07\n\x05Empty\"\x1d\n\x05Count\x12\x14\n\x05count\x18\x01\ + \x20\x01(\x03R\x05count\"\x1a\n\x04Bool\x12\x12\n\x04bool\x18\x01\x20\ + \x01(\x08R\x04bool\"&\n\x08PlayerID\x12\x1a\n\x08playerID\x18\x01\x20\ + \x01(\tR\x08playerID\"\"\n\x0cPlayerIDList\x12\x12\n\x04list\x18\x01\x20\ + \x03(\tR\x04list2\xa9\x06\n\x03SDK\x12m\n\rPlayerConnect\x12\x1e.agones.\ + dev.sdk.alpha.PlayerID\x1a\x1a.agones.dev.sdk.alpha.Bool\"\x20\x82\xd3\ + \xe4\x93\x02\x1a\"\x15/alpha/player/connect:\x01*\x12s\n\x10PlayerDiscon\ + nect\x12\x1e.agones.dev.sdk.alpha.PlayerID\x1a\x1a.agones.dev.sdk.alpha.\ + Bool\"#\x82\xd3\xe4\x93\x02\x1d\"\x18/alpha/player/disconnect:\x01*\x12p\ + \n\x11SetPlayerCapacity\x12\x1b.agones.dev.sdk.alpha.Count\x1a\x1b.agone\ + s.dev.sdk.alpha.Empty\"!\x82\xd3\xe4\x93\x02\x1b\x1a\x16/alpha/player/ca\ + pacity:\x01*\x12m\n\x11GetPlayerCapacity\x12\x1b.agones.dev.sdk.alpha.Em\ + pty\x1a\x1b.agones.dev.sdk.alpha.Count\"\x1e\x82\xd3\xe4\x93\x02\x18\x12\ + \x16/alpha/player/capacity\x12g\n\x0eGetPlayerCount\x12\x1b.agones.dev.s\ + dk.alpha.Empty\x1a\x1b.agones.dev.sdk.alpha.Count\"\x1b\x82\xd3\xe4\x93\ + \x02\x15\x12\x13/alpha/player/count\x12{\n\x11IsPlayerConnected\x12\x1e.\ + agones.dev.sdk.alpha.PlayerID\x1a\x1a.agones.dev.sdk.alpha.Bool\"*\x82\ + \xd3\xe4\x93\x02$\x12\"/alpha/player/connected/{playerID}\x12w\n\x13GetC\ + onnectedPlayers\x12\x1b.agones.dev.sdk.alpha.Empty\x1a\".agones.dev.sdk.\ + alpha.PlayerIDList\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/alpha/player/co\ + nnectedB\x07Z\x05alphaJ\xd0)\n\x07\x12\x05\x0e\0\x89\x01\x01\n\xd1\x04\n\ + \x01\x0c\x12\x03\x0e\0\x122\xc6\x04\x20Copyright\x202020\x20Google\x20LL\ + C\x20All\x20Rights\x20Reserved.\n\n\x20Licensed\x20under\x20the\x20Apach\ + e\x20License,\x20Version\x202.0\x20(the\x20\"License\");\n\x20you\x20may\ + \x20not\x20use\x20this\x20file\x20except\x20in\x20compliance\x20with\x20\ + the\x20License.\n\x20You\x20may\x20obtain\x20a\x20copy\x20of\x20the\x20L\ + icense\x20at\n\n\x20\x20\x20\x20\x20http://www.apache.org/licenses/LICEN\ + SE-2.0\n\n\x20Unless\x20required\x20by\x20applicable\x20law\x20or\x20agr\ + eed\x20to\x20in\x20writing,\x20software\n\x20distributed\x20under\x20the\ + \x20License\x20is\x20distributed\x20on\x20an\x20\"AS\x20IS\"\x20BASIS,\n\ + \x20WITHOUT\x20WARRANTIES\x20OR\x20CONDITIONS\x20OF\x20ANY\x20KIND,\x20e\ + ither\x20express\x20or\x20implied.\n\x20See\x20the\x20License\x20for\x20\ + the\x20specific\x20language\x20governing\x20permissions\x20and\n\x20limi\ + tations\x20under\x20the\x20License.\n\n\x08\n\x01\x02\x12\x03\x10\0\x1d\ + \n\x08\n\x01\x08\x12\x03\x11\0\x1c\n\t\n\x02\x08\x0b\x12\x03\x11\0\x1c\n\ + \t\n\x02\x03\0\x12\x03\x13\0&\nN\n\x02\x06\0\x12\x04\x16\0q\x01\x1aB\x20\ + SDK\x20service\x20to\x20be\x20used\x20in\x20the\x20GameServer\x20SDK\x20\ + to\x20the\x20Pod\x20Sidecar.\n\n\n\n\x03\x06\0\x01\x12\x03\x16\x08\x0b\n\ + \xbe\x08\n\x04\x06\0\x02\0\x12\x04'\x04,\x05\x1a\xaf\x08\x20PlayerConnec\ + t\x20increases\x20the\x20SDK\xe2\x80\x99s\x20stored\x20player\x20count\ + \x20by\x20one,\x20and\x20appends\x20this\x20playerID\x20to\x20GameServer\ + .Status.Players.IDs.\n\n\x20GameServer.Status.Players.Count\x20and\x20Ga\ + meServer.Status.Players.IDs\x20are\x20then\x20set\x20to\x20update\x20the\ + \x20player\x20count\x20and\x20id\x20list\x20a\x20second\x20from\x20now,\ + \n\x20unless\x20there\x20is\x20already\x20an\x20update\x20pending,\x20in\ + \x20which\x20case\x20the\x20update\x20joins\x20that\x20batch\x20operatio\ + n.\n\n\x20PlayerConnect\x20returns\x20true\x20and\x20adds\x20the\x20play\ + erID\x20to\x20the\x20list\x20of\x20playerIDs\x20if\x20this\x20playerID\ + \x20was\x20not\x20already\x20in\x20the\n\x20list\x20of\x20connected\x20p\ + layerIDs.\n\n\x20If\x20the\x20playerID\x20exists\x20within\x20the\x20lis\ + t\x20of\x20connected\x20playerIDs,\x20PlayerConnect\x20will\x20return\ + \x20false,\x20and\x20the\x20list\x20of\n\x20connected\x20playerIDs\x20wi\ + ll\x20be\x20left\x20unchanged.\n\n\x20An\x20error\x20will\x20be\x20retur\ + ned\x20if\x20the\x20playerID\x20was\x20not\x20already\x20in\x20the\x20li\ + st\x20of\x20connected\x20playerIDs\x20but\x20the\x20player\x20capacity\ + \x20for\n\x20the\x20server\x20has\x20been\x20reached.\x20The\x20playerID\ + \x20will\x20not\x20be\x20added\x20to\x20the\x20list\x20of\x20playerIDs.\ + \n\n\x20Warning:\x20Do\x20not\x20use\x20this\x20method\x20if\x20you\x20a\ + re\x20manually\x20managing\x20GameServer.Status.Players.IDs\x20and\x20Ga\ + meServer.Status.Players.Count\n\x20through\x20the\x20Kubernetes\x20API,\ + \x20as\x20indeterminate\x20results\x20will\x20occur.\n\n\x0c\n\x05\x06\0\ + \x02\0\x01\x12\x03'\x08\x15\n\x0c\n\x05\x06\0\x02\0\x02\x12\x03'\x17\x1f\ + \n\x0c\n\x05\x06\0\x02\0\x03\x12\x03'*.\n\r\n\x05\x06\0\x02\0\x04\x12\ + \x04(\x08+\n\n\x11\n\t\x06\0\x02\0\x04\xb0\xca\xbc\"\x12\x04(\x08+\n\n\ + \xda\x06\n\x04\x06\0\x02\x01\x12\x04;\x04@\x05\x1a\xcb\x06\x20Decreases\ + \x20the\x20SDK\xe2\x80\x99s\x20stored\x20player\x20count\x20by\x20one,\ + \x20and\x20removes\x20the\x20playerID\x20from\x20GameServer.Status.Playe\ + rs.IDs.\n\n\x20GameServer.Status.Players.Count\x20and\x20GameServer.Stat\ + us.Players.IDs\x20are\x20then\x20set\x20to\x20update\x20the\x20player\ + \x20count\x20and\x20id\x20list\x20a\x20second\x20from\x20now,\n\x20unles\ + s\x20there\x20is\x20already\x20an\x20update\x20pending,\x20in\x20which\ + \x20case\x20the\x20update\x20joins\x20that\x20batch\x20operation.\n\n\ + \x20PlayerDisconnect\x20will\x20return\x20true\x20and\x20remove\x20the\ + \x20supplied\x20playerID\x20from\x20the\x20list\x20of\x20connected\x20pl\ + ayerIDs\x20if\x20the\n\x20playerID\x20value\x20exists\x20within\x20the\ + \x20list.\n\n\x20If\x20the\x20playerID\x20was\x20not\x20in\x20the\x20lis\ + t\x20of\x20connected\x20playerIDs,\x20the\x20call\x20will\x20return\x20f\ + alse,\x20and\x20the\x20connected\x20playerID\x20list\n\x20will\x20be\x20\ + left\x20unchanged.\n\n\x20Warning:\x20Do\x20not\x20use\x20this\x20method\ + \x20if\x20you\x20are\x20manually\x20managing\x20GameServer.status.player\ + s.IDs\x20and\x20GameServer.status.players.Count\n\x20through\x20the\x20K\ + ubernetes\x20API,\x20as\x20indeterminate\x20results\x20will\x20occur.\n\ + \n\x0c\n\x05\x06\0\x02\x01\x01\x12\x03;\x08\x18\n\x0c\n\x05\x06\0\x02\ + \x01\x02\x12\x03;\x1a\"\n\x0c\n\x05\x06\0\x02\x01\x03\x12\x03;-1\n\r\n\ + \x05\x06\0\x02\x01\x04\x12\x04<\x08?\n\n\x11\n\t\x06\0\x02\x01\x04\xb0\ + \xca\xbc\"\x12\x04<\x08?\n\nX\n\x04\x06\0\x02\x02\x12\x04C\x04H\x05\x1aJ\ + \x20Update\x20the\x20GameServer.Status.Players.Capacity\x20value\x20with\ + \x20a\x20new\x20capacity.\n\n\x0c\n\x05\x06\0\x02\x02\x01\x12\x03C\x08\ + \x19\n\x0c\n\x05\x06\0\x02\x02\x02\x12\x03C\x1b\x20\n\x0c\n\x05\x06\0\ + \x02\x02\x03\x12\x03C+0\n\r\n\x05\x06\0\x02\x02\x04\x12\x04D\x08G\n\n\ + \x11\n\t\x06\0\x02\x02\x04\xb0\xca\xbc\"\x12\x04D\x08G\n\n\xe2\x02\n\x04\ + \x06\0\x02\x03\x12\x04N\x04R\x05\x1a\xd3\x02\x20Retrieves\x20the\x20curr\ + ent\x20player\x20capacity.\x20This\x20is\x20always\x20accurate\x20from\ + \x20what\x20has\x20been\x20set\x20through\x20this\x20SDK,\n\x20even\x20i\ + f\x20the\x20value\x20has\x20yet\x20to\x20be\x20updated\x20on\x20the\x20G\ + ameServer\x20status\x20resource.\n\n\x20If\x20GameServer.Status.Players.\ + Capacity\x20is\x20set\x20manually\x20through\x20the\x20Kubernetes\x20API\ + ,\x20use\x20SDK.GameServer()\x20or\x20SDK.WatchGameServer()\x20instead\ + \x20to\x20view\x20this\x20value.\n\n\x0c\n\x05\x06\0\x02\x03\x01\x12\x03\ + N\x08\x19\n\x0c\n\x05\x06\0\x02\x03\x02\x12\x03N\x1b\x20\n\x0c\n\x05\x06\ + \0\x02\x03\x03\x12\x03N+0\n\r\n\x05\x06\0\x02\x03\x04\x12\x04O\x08Q\n\n\ + \x11\n\t\x06\0\x02\x03\x04\xb0\xca\xbc\"\x12\x04O\x08Q\n\n\xdc\x02\n\x04\ + \x06\0\x02\x04\x12\x04X\x04\\\x05\x1a\xcd\x02\x20Retrieves\x20the\x20cur\ + rent\x20player\x20count.\x20This\x20is\x20always\x20accurate\x20from\x20\ + what\x20has\x20been\x20set\x20through\x20this\x20SDK,\n\x20even\x20if\ + \x20the\x20value\x20has\x20yet\x20to\x20be\x20updated\x20on\x20the\x20Ga\ + meServer\x20status\x20resource.\n\n\x20If\x20GameServer.Status.Players.C\ + ount\x20is\x20set\x20manually\x20through\x20the\x20Kubernetes\x20API,\ + \x20use\x20SDK.GameServer()\x20or\x20SDK.WatchGameServer()\x20instead\ + \x20to\x20view\x20this\x20value.\n\n\x0c\n\x05\x06\0\x02\x04\x01\x12\x03\ + X\x08\x16\n\x0c\n\x05\x06\0\x02\x04\x02\x12\x03X\x18\x1d\n\x0c\n\x05\x06\ + \0\x02\x04\x03\x12\x03X(-\n\r\n\x05\x06\0\x02\x04\x04\x12\x04Y\x08[\n\n\ + \x11\n\t\x06\0\x02\x04\x04\xb0\xca\xbc\"\x12\x04Y\x08[\n\n\x83\x03\n\x04\ + \x06\0\x02\x05\x12\x04b\x04f\x05\x1a\xf4\x02\x20Returns\x20if\x20the\x20\ + playerID\x20is\x20currently\x20connected\x20to\x20the\x20GameServer.\x20\ + This\x20is\x20always\x20accurate\x20from\x20what\x20has\x20been\x20set\ + \x20through\x20this\x20SDK,\n\x20even\x20if\x20the\x20value\x20has\x20ye\ + t\x20to\x20be\x20updated\x20on\x20the\x20GameServer\x20status\x20resourc\ + e.\n\n\x20If\x20GameServer.Status.Players.IDs\x20is\x20set\x20manually\ + \x20through\x20the\x20Kubernetes\x20API,\x20use\x20SDK.GameServer()\x20o\ + r\x20SDK.WatchGameServer()\x20instead\x20to\x20determine\x20connected\ + \x20status.\n\n\x0c\n\x05\x06\0\x02\x05\x01\x12\x03b\x08\x19\n\x0c\n\x05\ + \x06\0\x02\x05\x02\x12\x03b\x1b#\n\x0c\n\x05\x06\0\x02\x05\x03\x12\x03b.\ + 2\n\r\n\x05\x06\0\x02\x05\x04\x12\x04c\x08e\n\n\x11\n\t\x06\0\x02\x05\ + \x04\xb0\xca\xbc\"\x12\x04c\x08e\n\n\xee\x02\n\x04\x06\0\x02\x06\x12\x04\ + l\x04p\x05\x1a\xdf\x02\x20Returns\x20the\x20list\x20of\x20the\x20current\ + ly\x20connected\x20player\x20ids.\x20This\x20is\x20always\x20accurate\ + \x20from\x20what\x20has\x20been\x20set\x20through\x20this\x20SDK,\n\x20e\ + ven\x20if\x20the\x20value\x20has\x20yet\x20to\x20be\x20updated\x20on\x20\ + the\x20GameServer\x20status\x20resource.\n\n\x20If\x20GameServer.Status.\ + Players.IDs\x20is\x20set\x20manually\x20through\x20the\x20Kubernetes\x20\ + API,\x20use\x20SDK.GameServer()\x20or\x20SDK.WatchGameServer()\x20instea\ + d\x20to\x20view\x20this\x20value.\n\n\x0c\n\x05\x06\0\x02\x06\x01\x12\ + \x03l\x08\x1b\n\x0c\n\x05\x06\0\x02\x06\x02\x12\x03l\x1c!\n\x0c\n\x05\ + \x06\0\x02\x06\x03\x12\x03l,8\n\r\n\x05\x06\0\x02\x06\x04\x12\x04m\x08o\ + \n\n\x11\n\t\x06\0\x02\x06\x04\xb0\xca\xbc\"\x12\x04m\x08o\n\n\x18\n\x02\ + \x04\0\x12\x04t\0u\x01\x1a\x0c\x20I\x20am\x20Empty\n\n\n\n\x03\x04\0\x01\ + \x12\x03t\x08\r\n%\n\x02\x04\x01\x12\x04x\0z\x01\x1a\x19\x20Store\x20a\ + \x20count\x20variable.\n\n\n\n\x03\x04\x01\x01\x12\x03x\x08\r\n\x0b\n\ + \x04\x04\x01\x02\0\x12\x03y\x04\x14\n\r\n\x05\x04\x01\x02\0\x04\x12\x04y\ + \x04x\x0f\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03y\x04\t\n\x0c\n\x05\x04\ + \x01\x02\0\x01\x12\x03y\n\x0f\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03y\x12\ + \x13\n$\n\x02\x04\x02\x12\x04}\0\x7f\x01\x1a\x18\x20Store\x20a\x20boolea\ + n\x20result\n\n\n\n\x03\x04\x02\x01\x12\x03}\x08\x0c\n\x0b\n\x04\x04\x02\ + \x02\0\x12\x03~\x04\x12\n\r\n\x05\x04\x02\x02\0\x04\x12\x04~\x04}\x0e\n\ + \x0c\n\x05\x04\x02\x02\0\x05\x12\x03~\x04\x08\n\x0c\n\x05\x04\x02\x02\0\ + \x01\x12\x03~\t\r\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03~\x10\x11\n9\n\ + \x02\x04\x03\x12\x06\x82\x01\0\x84\x01\x01\x1a+\x20The\x20unique\x20iden\ + tifier\x20for\x20a\x20given\x20player.\n\n\x0b\n\x03\x04\x03\x01\x12\x04\ + \x82\x01\x08\x10\n\x0c\n\x04\x04\x03\x02\0\x12\x04\x83\x01\x04\x18\n\x0f\ + \n\x05\x04\x03\x02\0\x04\x12\x06\x83\x01\x04\x82\x01\x12\n\r\n\x05\x04\ + \x03\x02\0\x05\x12\x04\x83\x01\x04\n\n\r\n\x05\x04\x03\x02\0\x01\x12\x04\ + \x83\x01\x0b\x13\n\r\n\x05\x04\x03\x02\0\x03\x12\x04\x83\x01\x16\x17\n\"\ + \n\x02\x04\x04\x12\x06\x87\x01\0\x89\x01\x01\x1a\x14\x20List\x20of\x20Pl\ + ayer\x20IDs\n\n\x0b\n\x03\x04\x04\x01\x12\x04\x87\x01\x08\x14\n\x0c\n\ + \x04\x04\x04\x02\0\x12\x04\x88\x01\x04\x1d\n\r\n\x05\x04\x04\x02\0\x04\ + \x12\x04\x88\x01\x04\x0c\n\r\n\x05\x04\x04\x02\0\x05\x12\x04\x88\x01\r\ + \x13\n\r\n\x05\x04\x04\x02\0\x01\x12\x04\x88\x01\x14\x18\n\r\n\x05\x04\ + \x04\x02\0\x03\x12\x04\x88\x01\x1b\x1cb\x06proto3\ +"; + +static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { + lock: ::protobuf::lazy::ONCE_INIT, + ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, +}; + +fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { + ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() +} + +pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { + unsafe { + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) + } +} diff --git a/sdks/rust/src/grpc/alpha_grpc.rs b/sdks/rust/src/grpc/alpha_grpc.rs new file mode 100644 index 0000000000..78ff246e5e --- /dev/null +++ b/sdks/rust/src/grpc/alpha_grpc.rs @@ -0,0 +1,253 @@ +// 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. + +// This code was autogenerated. Do not edit directly. +// This file is generated. Do not edit +// @generated + +// https://github.com/Manishearth/rust-clippy/issues/702 +#![allow(unknown_lints)] +#![allow(clippy)] + +#![cfg_attr(rustfmt, rustfmt_skip)] + +#![allow(box_pointers)] +#![allow(dead_code)] +#![allow(missing_docs)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(non_upper_case_globals)] +#![allow(trivial_casts)] +#![allow(unsafe_code)] +#![allow(unused_imports)] +#![allow(unused_results)] + +const METHOD_SDK_PLAYER_CONNECT: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/PlayerConnect", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_PLAYER_DISCONNECT: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/PlayerDisconnect", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_SET_PLAYER_CAPACITY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/SetPlayerCapacity", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_GET_PLAYER_CAPACITY: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/GetPlayerCapacity", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_GET_PLAYER_COUNT: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/GetPlayerCount", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_IS_PLAYER_CONNECTED: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/IsPlayerConnected", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +const METHOD_SDK_GET_CONNECTED_PLAYERS: ::grpcio::Method = ::grpcio::Method { + ty: ::grpcio::MethodType::Unary, + name: "/agones.dev.sdk.alpha.SDK/GetConnectedPlayers", + req_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, + resp_mar: ::grpcio::Marshaller { ser: ::grpcio::pb_ser, de: ::grpcio::pb_de }, +}; + +pub struct SdkClient { + client: ::grpcio::Client, +} + +impl SdkClient { + pub fn new(channel: ::grpcio::Channel) -> Self { + SdkClient { + client: ::grpcio::Client::new(channel), + } + } + + pub fn player_connect_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_PLAYER_CONNECT, req, opt) + } + + pub fn player_connect(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result { + self.player_connect_opt(req, ::grpcio::CallOption::default()) + } + + pub fn player_connect_async_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_PLAYER_CONNECT, req, opt) + } + + pub fn player_connect_async(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.player_connect_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn player_disconnect_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_PLAYER_DISCONNECT, req, opt) + } + + pub fn player_disconnect(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result { + self.player_disconnect_opt(req, ::grpcio::CallOption::default()) + } + + pub fn player_disconnect_async_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_PLAYER_DISCONNECT, req, opt) + } + + pub fn player_disconnect_async(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.player_disconnect_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn set_player_capacity_opt(&self, req: &super::alpha::Count, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_SET_PLAYER_CAPACITY, req, opt) + } + + pub fn set_player_capacity(&self, req: &super::alpha::Count) -> ::grpcio::Result { + self.set_player_capacity_opt(req, ::grpcio::CallOption::default()) + } + + pub fn set_player_capacity_async_opt(&self, req: &super::alpha::Count, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_SET_PLAYER_CAPACITY, req, opt) + } + + pub fn set_player_capacity_async(&self, req: &super::alpha::Count) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.set_player_capacity_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_player_capacity_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_GET_PLAYER_CAPACITY, req, opt) + } + + pub fn get_player_capacity(&self, req: &super::alpha::Empty) -> ::grpcio::Result { + self.get_player_capacity_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_player_capacity_async_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_GET_PLAYER_CAPACITY, req, opt) + } + + pub fn get_player_capacity_async(&self, req: &super::alpha::Empty) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_player_capacity_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_player_count_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_GET_PLAYER_COUNT, req, opt) + } + + pub fn get_player_count(&self, req: &super::alpha::Empty) -> ::grpcio::Result { + self.get_player_count_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_player_count_async_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_GET_PLAYER_COUNT, req, opt) + } + + pub fn get_player_count_async(&self, req: &super::alpha::Empty) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_player_count_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn is_player_connected_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_IS_PLAYER_CONNECTED, req, opt) + } + + pub fn is_player_connected(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result { + self.is_player_connected_opt(req, ::grpcio::CallOption::default()) + } + + pub fn is_player_connected_async_opt(&self, req: &super::alpha::PlayerID, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_IS_PLAYER_CONNECTED, req, opt) + } + + pub fn is_player_connected_async(&self, req: &super::alpha::PlayerID) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.is_player_connected_async_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_connected_players_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result { + self.client.unary_call(&METHOD_SDK_GET_CONNECTED_PLAYERS, req, opt) + } + + pub fn get_connected_players(&self, req: &super::alpha::Empty) -> ::grpcio::Result { + self.get_connected_players_opt(req, ::grpcio::CallOption::default()) + } + + pub fn get_connected_players_async_opt(&self, req: &super::alpha::Empty, opt: ::grpcio::CallOption) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.client.unary_call_async(&METHOD_SDK_GET_CONNECTED_PLAYERS, req, opt) + } + + pub fn get_connected_players_async(&self, req: &super::alpha::Empty) -> ::grpcio::Result<::grpcio::ClientUnaryReceiver> { + self.get_connected_players_async_opt(req, ::grpcio::CallOption::default()) + } + pub fn spawn(&self, f: F) where F: ::futures::Future + Send + 'static { + self.client.spawn(f) + } +} + +pub trait Sdk { + fn player_connect(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn player_disconnect(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn set_player_capacity(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Count, sink: ::grpcio::UnarySink); + fn get_player_capacity(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); + fn get_player_count(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); + fn is_player_connected(&self, ctx: ::grpcio::RpcContext, req: super::alpha::PlayerID, sink: ::grpcio::UnarySink); + fn get_connected_players(&self, ctx: ::grpcio::RpcContext, req: super::alpha::Empty, sink: ::grpcio::UnarySink); +} + +pub fn create_sdk(s: S) -> ::grpcio::Service { + let mut builder = ::grpcio::ServiceBuilder::new(); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_PLAYER_CONNECT, move |ctx, req, resp| { + instance.player_connect(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_PLAYER_DISCONNECT, move |ctx, req, resp| { + instance.player_disconnect(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_SET_PLAYER_CAPACITY, move |ctx, req, resp| { + instance.set_player_capacity(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_GET_PLAYER_CAPACITY, move |ctx, req, resp| { + instance.get_player_capacity(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_GET_PLAYER_COUNT, move |ctx, req, resp| { + instance.get_player_count(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_IS_PLAYER_CONNECTED, move |ctx, req, resp| { + instance.is_player_connected(ctx, req, resp) + }); + let instance = s.clone(); + builder = builder.add_unary_handler(&METHOD_SDK_GET_CONNECTED_PLAYERS, move |ctx, req, resp| { + instance.get_connected_players(ctx, req, resp) + }); + builder.build() +} diff --git a/sdks/rust/src/grpc/mod.rs b/sdks/rust/src/grpc/mod.rs index 9051a9c920..340d2db509 100644 --- a/sdks/rust/src/grpc/mod.rs +++ b/sdks/rust/src/grpc/mod.rs @@ -12,5 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub mod alpha; +pub mod alpha_grpc; pub mod sdk; pub mod sdk_grpc; diff --git a/sdks/rust/src/lib.rs b/sdks/rust/src/lib.rs index ef63c01417..7f649871bf 100644 --- a/sdks/rust/src/lib.rs +++ b/sdks/rust/src/lib.rs @@ -20,6 +20,7 @@ extern crate grpcio; extern crate grpcio_proto; extern crate protobuf; +pub mod alpha; pub mod errors; mod grpc; mod sdk; diff --git a/sdks/rust/src/sdk.rs b/sdks/rust/src/sdk.rs index 1819c6df94..0b59bea948 100644 --- a/sdks/rust/src/sdk.rs +++ b/sdks/rust/src/sdk.rs @@ -21,6 +21,7 @@ use futures::{Future, Sink, Stream}; use grpcio; use protobuf::Message; +use alpha::*; use errors::*; use grpc::sdk; use grpc::sdk_grpc; @@ -30,6 +31,7 @@ use types::*; pub struct Sdk { client: Arc, health: Arc>>>, + alpha: Arc, } impl Sdk { @@ -43,7 +45,8 @@ impl Sdk { let ch = grpcio::ChannelBuilder::new(env) .keepalive_timeout(Duration::new(30, 0)) .connect(&addr); - let cli = sdk_grpc::SdkClient::new(ch); + let cli = sdk_grpc::SdkClient::new(ch.clone()); + let alpha = Alpha::new(ch); let req = sdk::Empty::new(); // Unfortunately there isn't a native way to block until connected @@ -67,9 +70,15 @@ impl Sdk { Ok(Sdk { client: Arc::new(cli), health: Arc::new(Mutex::new(Some(sender))), + alpha: Arc::new(alpha), }) } + /// Alpha returns the Alpha SDK + pub fn alpha(&self) -> &Arc { + &self.alpha + } + /// Marks the Game Server as ready to receive connections pub fn ready(&self) -> Result<()> { let req = sdk::Empty::default_instance(); @@ -190,6 +199,7 @@ impl Clone for Sdk { Self { client: Arc::clone(&self.client), health: self.health.clone(), + alpha: Arc::clone(&self.alpha), } } } diff --git a/sdks/rust/src/types.rs b/sdks/rust/src/types.rs index c94e5d573f..cf3937901e 100644 --- a/sdks/rust/src/types.rs +++ b/sdks/rust/src/types.rs @@ -112,6 +112,7 @@ pub struct GameServerStatus { pub state: String, pub address: String, pub ports: Vec, + pub players: Option, } impl GameServerStatus { @@ -124,6 +125,10 @@ impl GameServerStatus { .into_iter() .map(|e| GameServerStatusPort::from_message(e)) .collect(), + players: msg + .players + .into_option() + .map(|e| GameServerStatusPlayersStatus::from_message(e)), } } } @@ -142,3 +147,20 @@ impl GameServerStatusPort { } } } + +#[derive(PartialEq, Clone, Default)] +pub struct GameServerStatusPlayersStatus { + pub count: i64, + pub capacity: i64, + pub ids: Vec, +} + +impl GameServerStatusPlayersStatus { + pub fn from_message(msg: sdk::GameServer_Status_PlayerStatus) -> GameServerStatusPlayersStatus { + GameServerStatusPlayersStatus { + count: msg.count, + capacity: msg.capacity, + ids: msg.ids.into(), + } + } +} diff --git a/test/sdk/rust/src/main.rs b/test/sdk/rust/src/main.rs index a0cd8a8b03..1a60de49a7 100644 --- a/test/sdk/rust/src/main.rs +++ b/test/sdk/rust/src/main.rs @@ -14,6 +14,7 @@ extern crate agones; +use std::env; use std::result::Result; use std::thread; use std::time::Duration; @@ -112,6 +113,11 @@ fn run() -> Result<(), String> { sdk.set_label("test-label", &creation_ts.to_string()) .map_err(|e| format!("Could not run SetLabel(): {}. Exiting!", e))?; + let feature_gates = env::var("FEATURE_GATES").unwrap_or("".to_string()); + if feature_gates.contains("PlayerTracking=true") { + run_player_tracking_features(&sdk)?; + } + for i in 0..1 { let time = i * 5; println!("Running for {} seconds", time); @@ -125,3 +131,70 @@ fn run() -> Result<(), String> { println!("...marked for Shutdown"); Ok(()) } + +fn run_player_tracking_features(sdk: &agones::Sdk) -> Result<(), String> { + println!("Setting player capacity..."); + sdk.alpha() + .set_player_capacity(10) + .map_err(|e| format!("Could not run SetPlayerCapacity(): {}. Exiting!", e))?; + + println!("Getting player capacity..."); + let capacity = sdk + .alpha() + .get_player_capacity() + .map_err(|e| format!("Could not run GetPlayerCapacity(): {}. Exiting!", e))?; + println!("Player capacity: {}", capacity); + + println!("Increasing the player count..."); + let player_id = "1234".to_string(); + let added = sdk + .alpha() + .player_connect(&player_id) + .map_err(|e| format!("Could not run PlayerConnect(): {}. Exiting!", e))?; + if added { + println!("Added player"); + } else { + panic!("Failed to add player. Exiting!"); + } + + let connected = sdk + .alpha() + .is_player_connected(&player_id) + .map_err(|e| format!("Could not run IsPlayerConnected(): {}. Exiting!", e))?; + if connected { + println!("{} is connected", player_id); + } else { + panic!("{} is not connected. Exiting!", player_id); + } + + let player_ids = sdk + .alpha() + .get_connected_players() + .map_err(|e| format!("Could not run GetConnectedPlayers(): {}. Exiting!", e))?; + println!("Connected players: {:?}", player_ids); + + let player_count = sdk + .alpha() + .get_player_count() + .map_err(|e| format!("Could not run GetConnectedPlayers(): {}. Exiting!", e))?; + println!("Current player count: {}", player_count); + + println!("Decreasing the player count..."); + let removed = sdk + .alpha() + .player_disconnect(&player_id) + .map_err(|e| format!("Could not run PlayerDisconnect(): {}. Exiting!", e))?; + if removed { + println!("Removed player"); + } else { + panic!("Failed to remove player. Exiting!"); + } + + let player_count = sdk + .alpha() + .get_player_count() + .map_err(|e| format!("Could not GetPlayerCount(): {}. Exiting!", e))?; + println!("Current player count: {}", player_count); + + Ok(()) +}