Skip to content

Commit

Permalink
C++ SDK: Update the function signature of WatchGameServer to use a
Browse files Browse the repository at this point in the history
const-reference. Also update the simple cpp example so that it still
compiles.
  • Loading branch information
roberthbailey committed Jul 26, 2019
1 parent fa1eb4a commit 180791f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/cpp-simple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ REPOSITORY = gcr.io/agones-images
# Directory that this Makefile is in.
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
server_tag = $(REPOSITORY)/cpp-simple-server:0.9
server_tag = $(REPOSITORY)/cpp-simple-server:0.10
root_path = $(realpath $(project_path)/../..)

# _____ _
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp-simple/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DoHealth(std::shared_ptr<agones::SDK> sdk) {
// watch GameServer Updates
void WatchUpdates(std::shared_ptr<agones::SDK> sdk) {
std::cout << "Starting to watch GameServer updates...\n" << std::flush;
sdk->WatchGameServer([](agones::dev::sdk::GameServer gameserver) {
sdk->WatchGameServer([](const agones::dev::sdk::GameServer& gameserver) {
std::cout << "GameServer Update:\n" //
<< "\tname: " << gameserver.object_meta().name() << "\n" //
<< "\tstate: " << gameserver.status().state() << "\n"
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/include/agones/sdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SDK {
// This is a blocking function, and as such you will likely want to run it
// inside a thread.
AGONES_EXPORT grpc::Status WatchGameServer(
const std::function<void(agones::dev::sdk::GameServer)>& callback);
const std::function<void(const agones::dev::sdk::GameServer&)>& callback);

private:
struct SDKImpl;
Expand Down
2 changes: 1 addition & 1 deletion sdks/cpp/src/agones/sdk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ grpc::Status SDK::GameServer(agones::dev::sdk::GameServer* response) {
}

grpc::Status SDK::WatchGameServer(
const std::function<void(agones::dev::sdk::GameServer)>& callback) {
const std::function<void(const agones::dev::sdk::GameServer&)>& callback) {
grpc::ClientContext context;
agones::dev::sdk::Empty request;
agones::dev::sdk::GameServer gameServer;
Expand Down

0 comments on commit 180791f

Please sign in to comment.