gpg::GameServices

#include <game_services.h>

The starting point for interacting with Google Play Games.

Summary

Game Services Lifecycle

An instance of the GameServices class is created via a GameServices::Builder. When created, the instance is initially not signed into the Game Services (that is, IsAuthorized() will return false). A silent sign-in attempt is initiated in the background, and may succeed if a user was signed in at the end of a previous session. Until the completion of this silent sign-in attempt, any user authentication UI (for example, sign-in and/or sign-out buttons) should be disabled or hidden.

At the completion of this silent sign-in attempt, the OnAuthActionFinished callback for the GameServices instance (registered with GameServices::Builder::SetOnAuthActionFinished) will be notified. If the callback arguments reflect a successful sign-in attempt, the instance can be assumed to be connected to Game Services (that is, IsAuthorized() will return true), and sign-out UI should be enabled. If the callback argument reflects a failed sign-in attempt, sign-in UI should be enabled.

Explicit sign-out via the SignOut() method should be invoked only at user request. This requests a transition to a signed out state. The completion of this transition is indicated by an invocation of the OnAuthActionFinished callback. Until such a time as this callback is invoked, other GameServices APIs (including StartAuthorizationUI()) should not be called.

When a GameServices instance is destructed, it will block until there are no pending operations to avoid data loss. If this block-on-destruction behavior is not desired, a Flush() should be issued and the GameServices instance should be kept alive until the Flush() completes.

For GameServices to function properly on Android versions less than 4.0, the owning Activity must call lifecycle callbacks. See AndroidSupport.

Constructors and Destructors

GameServices()
~GameServices()

Public types

FlushCallback typedef
std::function< void(FlushStatus)>
Defines a callback type that receives the result (status) of a Flush operation.

Public functions

Achievements()
Provides a reference to the AchievementManager object used for accessing and manipulating achievements.
Achievements() const
Provides a const reference to the AchievementManager object used for accessing and manipulating achievements.
Events()
Provides a reference to the EventManager object used for accessing and manipulating events.
Events() const
const EventManager &
Provides a const reference to the EventManager object used for accessing and manipulating events.
Flush(FlushCallback callback)
void
Asynchronously flushes the main dispatch queue, and returns the status of the flush to the provided FlushCallback.
FlushBlocking()
Synchronously flushes and gets a result (status) of the flush.
FlushBlocking(Timeout timeout)
Synchronously flushes and gets a result (status) of the flush.
IsAuthorized()
bool
Allows you to explicitly check the current authorization state.
Leaderboards()
Provides a reference to the LeaderboardManager object used for accessing and manipulating achievements.
Leaderboards() const
Provides a const reference to the LeaderboardManager object used for accessing and manipulating achievements.
Players()
Provides a reference to the PlayerManager object, which allows access to information about players.
Players() const
const PlayerManager &
Provides a const reference to the PlayerManager object, which allows access to information about players.
RealTimeMultiplayer()
Provides a reference to the RealTimeMultiplayerManager object, which allows access to RTMP related methods.
RealTimeMultiplayer() const
Provides a const reference to the RealTimeMultiplayerManager object, which allows access to RTMP related methods.
SignOut()
void
Begins the asynchronous sign-out process.
Snapshots()
Provides a reference to the SnapshotManager object used for accessing and manipulating snapshots.
Snapshots() const
const SnapshotManager &
Provides a const reference to the SnapshotManager object used for accessing and manipulating snapshots.
StartAuthorizationUI()
void
Brings up a platform-specific user authorization flow.
Stats()
Provides a reference to the StatsManager object used for accessing game and player statistics.
Stats() const
const StatsManager &
Provides a const reference to the StatsManager object used for accessing game and player statistics.
TurnBasedMultiplayer()
Provides a reference to the TurnBasedMultiplayerManager object, which allows access to TBMP related methods.
TurnBasedMultiplayer() const
Provides a const reference to the TurnBasedMultiplayerManager object, which allows access to TBMP related methods.
Video()
Provides a reference to the VideoManager object, which allows access to video related methods.
Video() const
const VideoManager &
Provides a const reference to the VideoManager object, which allows access to video related methods.

Classes

gpg::GameServices::Builder

Used for creating and configuring an instance of the GameServices class.

Public types

FlushCallback

std::function< void(FlushStatus)> FlushCallback

Defines a callback type that receives the result (status) of a Flush operation.

Used in Flush().

Public functions

Achievements

AchievementManager & Achievements()

Provides a reference to the AchievementManager object used for accessing and manipulating achievements.

Achievements

const AchievementManager & Achievements() const 

Provides a const reference to the AchievementManager object used for accessing and manipulating achievements.

Events

EventManager & Events()

Provides a reference to the EventManager object used for accessing and manipulating events.

Events

const EventManager & Events() const 

Provides a const reference to the EventManager object used for accessing and manipulating events.

Flush

void Flush(
  FlushCallback callback
)

Asynchronously flushes the main dispatch queue, and returns the status of the flush to the provided FlushCallback.

Possible statuses are: FLUSHED, ERROR_INTERNAL, and ERROR_VERSION_UPDATE_REQUIRED.

FlushBlocking

FlushStatus FlushBlocking()

Synchronously flushes and gets a result (status) of the flush.

Possible statuses are: FLUSHED, ERROR_INTERNAL, ERROR_NOT_AUTHORIZED, ERROR_VERSION_UPDATE_REQUIRED, and ERROR_TIMEOUT. Leaving this timeout unspecified makes this function call equivalent to calling FlushStatus FlushBlocking(Timeout), with Timeout specified as 10 years.

FlushBlocking

FlushStatus FlushBlocking(
  Timeout timeout
)

Synchronously flushes and gets a result (status) of the flush.

Possible statuses are: FLUSHED, ERROR_INTERNAL, ERROR_NOT_AUTHORIZED, ERROR_VERSION_UPDATE_REQUIRED, and ERROR_TIMEOUT. Specify the timeout as an arbitrary number of milliseconds.

GameServices

 GameServices()=delete

IsAuthorized

bool IsAuthorized()

Allows you to explicitly check the current authorization state.

SDK consumers are encouraged to register for AUTH_ACTION_* callbacks to handle authorization state changes, rather than polling.

Leaderboards

LeaderboardManager & Leaderboards()

Provides a reference to the LeaderboardManager object used for accessing and manipulating achievements.

Leaderboards

const LeaderboardManager & Leaderboards() const 

Provides a const reference to the LeaderboardManager object used for accessing and manipulating achievements.

Players

PlayerManager & Players()

Provides a reference to the PlayerManager object, which allows access to information about players.

Players

const PlayerManager & Players() const 

Provides a const reference to the PlayerManager object, which allows access to information about players.

RealTimeMultiplayer

RealTimeMultiplayerManager & RealTimeMultiplayer()

Provides a reference to the RealTimeMultiplayerManager object, which allows access to RTMP related methods.

RealTimeMultiplayer

const RealTimeMultiplayerManager & RealTimeMultiplayer() const 

Provides a const reference to the RealTimeMultiplayerManager object, which allows access to RTMP related methods.

SignOut

void SignOut()

Begins the asynchronous sign-out process.

After calling SignOut, you should not call any operations on GameServices until you receive the OnAuthActionFinishedCallback indicating a successful sign-out.

Snapshots

SnapshotManager & Snapshots()

Provides a reference to the SnapshotManager object used for accessing and manipulating snapshots.

Snapshots

const SnapshotManager & Snapshots() const 

Provides a const reference to the SnapshotManager object used for accessing and manipulating snapshots.

StartAuthorizationUI

void StartAuthorizationUI()

Brings up a platform-specific user authorization flow.

Stats

StatsManager & Stats()

Provides a reference to the StatsManager object used for accessing game and player statistics.

Stats

const StatsManager & Stats() const 

Provides a const reference to the StatsManager object used for accessing game and player statistics.

TurnBasedMultiplayer

TurnBasedMultiplayerManager & TurnBasedMultiplayer()

Provides a reference to the TurnBasedMultiplayerManager object, which allows access to TBMP related methods.

TurnBasedMultiplayer

const TurnBasedMultiplayerManager & TurnBasedMultiplayer() const 

Provides a const reference to the TurnBasedMultiplayerManager object, which allows access to TBMP related methods.

Video

VideoManager & Video()

Provides a reference to the VideoManager object, which allows access to video related methods.

Video

const VideoManager & Video() const 

Provides a const reference to the VideoManager object, which allows access to video related methods.

~GameServices

 ~GameServices()