This class is deprecated.
The Game Manager APIs are no longer supported and will be removed in a future release.
Provides access to the GameManager APIs. This class allows to send requests to a connected Google Cast receiver device and get updates when game state changes.
This class is thread safe.
Nested Class Summary
interface | GameManagerClient.GameManagerInstanceResult | This interface is deprecated. The Game Manager APIs are no longer supported and will be removed in a future release. | |
interface | GameManagerClient.GameManagerResult | This interface is deprecated. The Game Manager APIs are no longer supported and will be removed in a future release. | |
interface | GameManagerClient.Listener | This interface is deprecated. The Game Manager APIs are no longer supported and will be removed in a future release. |
Constant Summary
int | GAMEPLAY_STATE_LOADING | Gameplay indicating that the game is loading. |
int | GAMEPLAY_STATE_PAUSED | Gameplay state indicating that the game is paused. |
int | GAMEPLAY_STATE_RUNNING | Gameplay state indicating that the game is running. |
int | GAMEPLAY_STATE_SHOWING_INFO_SCREEN | Gameplay state indicating that the game is showing an information screen. |
int | GAMEPLAY_STATE_UNKNOWN | Unknown gameplay state. |
int | LOBBY_STATE_CLOSED | Lobby state indicating that the lobby is closed and not accepting players. |
int | LOBBY_STATE_OPEN | Lobby state indicating that the lobby is open and accepting players to join. |
int | LOBBY_STATE_UNKNOWN | Unknown lobby state. |
int | PLAYER_STATE_AVAILABLE | Player state indicating that the player is connected to the receiver and available to join a game. |
int | PLAYER_STATE_DROPPED | Player state indicating that the player is no longer connected to the receiver because of a network drop. |
int | PLAYER_STATE_IDLE | Player state indicating that the player is connected to the receiver, in the game , and idle. |
int | PLAYER_STATE_PLAYING | Player state indicating that the player is connected to the receiver, in the game , and actively playing. |
int | PLAYER_STATE_QUIT | Player state indicating that the player has purposefully chosen to disconnect from the receiver. |
int | PLAYER_STATE_READY | Player state indicating that the player is connected to the receiver, and ready to enter the game. |
int | PLAYER_STATE_UNKNOWN | Unknown player state. |
int | STATUS_INCORRECT_VERSION | Status code indicating the version of the game manager in this client library does not match the version of the game manager running on the cast receiver. |
int | STATUS_TOO_MANY_PLAYERS | Status code indicating the number of players connected and available on the receiver is greater than the maximum number of players specified in the configuration of the receiver game. |
Public Method Summary
void |
dispose()
Releases all resources associated with this object.
|
synchronized GameManagerState |
getCurrentState()
Returns the current state of the game manager.
|
static PendingResult<GameManagerClient.GameManagerInstanceResult> |
getInstanceFor(GoogleApiClient
googleApiClient, String
castSessionId)
Constructs a new GameManagerClient using the provided GoogleApiClient.
|
String |
getLastUsedPlayerId()
Returns the id of the last controllable player on which a player request was
performed and completed successfully.
|
boolean |
isDisposed()
Returns whether
dispose() has been called.
|
void |
sendGameMessage(String playerId,
JSONObject
extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to
the application.
|
void |
sendGameMessage(JSONObject
extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to
the application.
|
PendingResult<GameManagerClient.GameManagerResult> |
sendGameRequest(JSONObject
extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to
the application.
|
PendingResult<GameManagerClient.GameManagerResult> |
sendGameRequest(String playerId,
JSONObject
extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to
the application.
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerAvailableRequest(String playerId,
JSONObject
extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_AVAILABLE .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerAvailableRequest(JSONObject
extraMessageData)
Sends a request to the receiver to transition the last used player by this
sender into
PLAYER_STATE_AVAILABLE .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerIdleRequest(JSONObject
extraMessageData)
Sends a request to the receiver to transition the last used player by this
sender into
PLAYER_STATE_IDLE .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerIdleRequest(String playerId,
JSONObject
extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_IDLE .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerPlayingRequest(JSONObject
extraMessageData)
Sends a request to the receiver to transition the last used player by this
sender into
PLAYER_STATE_PLAYING .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerPlayingRequest(String playerId,
JSONObject
extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_PLAYING .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerQuitRequest(JSONObject
extraMessageData)
Sends a request to the receiver to transition the last used player by this
sender into
PLAYER_STATE_QUIT .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerQuitRequest(String playerId,
JSONObject
extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_QUIT .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerReadyRequest(String playerId,
JSONObject
extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_READY .
|
PendingResult<GameManagerClient.GameManagerResult> |
sendPlayerReadyRequest(JSONObject
extraMessageData)
Sends a request to the receiver to transition the last used player by this
sender into
PLAYER_STATE_READY .
|
void |
setListener(GameManagerClient.Listener
listener)
Set the game manager client listener, which will trigger callbacks when the
game receives updates from the receiver device.
|
void |
setSessionLabel(String
sessionLabel)
Sets the session label, which will be used as the prefix for log messages.
|
Inherited Method Summary
Constants
public static final int GAMEPLAY_STATE_LOADING
Gameplay indicating that the game is loading.
public static final int GAMEPLAY_STATE_PAUSED
Gameplay state indicating that the game is paused.
public static final int GAMEPLAY_STATE_RUNNING
Gameplay state indicating that the game is running.
public static final int GAMEPLAY_STATE_SHOWING_INFO_SCREEN
Gameplay state indicating that the game is showing an information screen.
public static final int GAMEPLAY_STATE_UNKNOWN
Unknown gameplay state.
public static final int LOBBY_STATE_CLOSED
Lobby state indicating that the lobby is closed and not accepting players.
public static final int LOBBY_STATE_OPEN
Lobby state indicating that the lobby is open and accepting players to join.
public static final int LOBBY_STATE_UNKNOWN
Unknown lobby state.
public static final int PLAYER_STATE_AVAILABLE
Player state indicating that the player is connected to the receiver and available to join a game.
public static final int PLAYER_STATE_DROPPED
Player state indicating that the player is no longer connected to the receiver because of a network drop.
public static final int PLAYER_STATE_IDLE
Player state indicating that the player is connected to the receiver, in the game , and idle.
public static final int PLAYER_STATE_PLAYING
Player state indicating that the player is connected to the receiver, in the game , and actively playing.
public static final int PLAYER_STATE_QUIT
Player state indicating that the player has purposefully chosen to disconnect from the receiver.
public static final int PLAYER_STATE_READY
Player state indicating that the player is connected to the receiver, and ready to enter the game.
public static final int PLAYER_STATE_UNKNOWN
Unknown player state.
public static final int STATUS_INCORRECT_VERSION
Status code indicating the version of the game manager in this client library does not match the version of the game manager running on the cast receiver.
public static final int STATUS_TOO_MANY_PLAYERS
Status code indicating the number of players connected and available on the receiver is greater than the maximum number of players specified in the configuration of the receiver game.
Public Methods
public void dispose ()
Releases all resources associated with this object. It will no longer get updates
for state changes on the receiver device. After calling this method, further
interactions with this object, except for
dispose()
and
isDisposed()
will raise an IllegalStateException
.
public synchronized GameManagerState getCurrentState ()
Returns the current state of the game manager.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public static PendingResult<GameManagerClient.GameManagerInstanceResult> getInstanceFor (GoogleApiClient googleApiClient, String castSessionId)
Constructs a new GameManagerClient using the provided GoogleApiClient. This is an async operation.
Parameters
googleApiClient | The API client with which to perform the operation. Must be connected and contain the correct APIs. |
---|---|
castSessionId | The session ID of the cast application session running on the receiver. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalArgumentException | if passed googleApiClient is null , not connected or it doesn't
contain the Cast API, or if castSessionId is null or empty. |
---|
public String getLastUsedPlayerId ()
Returns the id of the last controllable player on which a player request was
performed and completed successfully. This can be null
if no response from
the receiver has been received as the result of a player request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public boolean isDisposed ()
Returns whether
dispose()
has been called.
public void sendGameMessage (String playerId, JSONObject extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to the
application. The message will originate from the last used local player. This is a
fire-and-forget method. To track the progress of the message, use
sendGameRequest(String, JSONObject)
.
Parameters
playerId | The id of the controllable player sending this message. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public void sendGameMessage (JSONObject extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to the
application. The message will originate from the last used local player. This is a
fire-and-forget method. To track the progress of the message, use
sendGameRequest(String, JSONObject)
.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendGameRequest (JSONObject extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to the application. The message will originate from the last used controllable player. The receiver will send a response back to this sender.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendGameRequest (String playerId, JSONObject extraMessageData)
Sends a game specific message to the receiver, its contents are entirely up to the application. The receiver will send a response back to this sender.
Parameters
playerId | The id of the controllable player sending this message. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerAvailableRequest (String playerId, JSONObject extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_AVAILABLE
. If the player's transition is invalid, the
GameManagerClient.GameManagerResult
will contain an error. If the playerId
is null
, a new player will be registered and its player ID will be set as
the last used player id when the receiver responds to this request.
Parameters
playerId | The id of the controllable player to be affected by this state change. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerAvailableRequest (JSONObject extraMessageData)
Sends a request to the receiver to transition the last used player by this sender
into
PLAYER_STATE_AVAILABLE
. If this is not a valid transition for that player an
error will be returned in the result object. If the last used player is unknown, a new
player will be registered and its player ID will be set as the last used player when
the receiver responds to this request.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerIdleRequest (JSONObject extraMessageData)
Sends a request to the receiver to transition the last used player by this sender
into
PLAYER_STATE_IDLE
. If the player's transition is invalid, or if the last
used player is unknown, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerIdleRequest (String playerId, JSONObject extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_IDLE
. If the player's transition is invalid, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
playerId | The id of the controllable player to be affected by this state change. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerPlayingRequest (JSONObject extraMessageData)
Sends a request to the receiver to transition the last used player by this sender
into
PLAYER_STATE_PLAYING
. If the player's transition is invalid, or if the last
used player is unknown, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerPlayingRequest (String playerId, JSONObject extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_PLAYING
. If the player's transition is invalid, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
playerId | The id of the controllable player to be affected by this state change. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerQuitRequest (JSONObject extraMessageData)
Sends a request to the receiver to transition the last used player by this sender
into
PLAYER_STATE_QUIT
. If the last used player is unknown, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerQuitRequest (String playerId, JSONObject extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_QUIT
.
Parameters
playerId | The id of the controllable player to be affected by this state change. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerReadyRequest (String playerId, JSONObject extraMessageData)
Sends a request to the receiver to transition a player into
PLAYER_STATE_READY
. If the player's transition is invalid, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
playerId | The id of the controllable player to be affected by this state change. |
---|---|
extraMessageData | Custom application-specific data to pass along with the request. |
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
public PendingResult<GameManagerClient.GameManagerResult> sendPlayerReadyRequest (JSONObject extraMessageData)
Sends a request to the receiver to transition the last used player by this sender
into
PLAYER_STATE_READY
. If the player's transition is invalid, or if the last
used player is unknown, the
GameManagerClient.GameManagerResult
will contain an error.
Parameters
extraMessageData | Custom application-specific data to pass along with the request. |
---|
Returns
- A
PendingResult
which can be used to track the progress of the request.
Throws
IllegalStateException | If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
---|
See Also
public void setListener (GameManagerClient.Listener listener)
Set the game manager client listener, which will trigger callbacks when the game receives updates from the receiver device.
See Also
public void setSessionLabel (String sessionLabel)
Sets the session label, which will be used as the prefix for log messages.
Parameters
sessionLabel | The prefix for logging messages. If null or an empty string is
passed no operation will be performed. |
---|