java.lang.Object | |
↳ | com.google.android.gms.cast.games.GameManagerClient |
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 Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
GameManagerClient.GameManagerInstanceResult | Result of a game manager client creation command. | ||||||||||
GameManagerClient.GameManagerResult | Result of a game manager command. | ||||||||||
GameManagerClient.Listener | A listener that can be set in GameManagerClient to be notified when game manager
state is updated or when game messages are received for players controlled by this sender. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Releases all resources associated with this object.
| |||||||||||
Returns the current state of the game manager.
| |||||||||||
Constructs a new GameManagerClient using the provided GoogleApiClient.
| |||||||||||
Returns the id of the last controllable player on which a player request was performed and
completed successfully.
| |||||||||||
Returns whether
dispose() has been called. | |||||||||||
Sends a game specific message to the receiver, its contents are entirely up to the
application.
| |||||||||||
Sends a game specific message to the receiver, its contents are entirely up to the
application.
| |||||||||||
Sends a game specific message to the receiver, its contents are entirely up to the
application.
| |||||||||||
Sends a game specific message to the receiver, its contents are entirely up to the
application.
| |||||||||||
Sends a request to the receiver to transition a player into
PLAYER_STATE_AVAILABLE . | |||||||||||
Sends a request to the receiver to transition the last used player by this sender into
PLAYER_STATE_AVAILABLE . | |||||||||||
Sends a request to the receiver to transition the last used player by this sender into
PLAYER_STATE_IDLE . | |||||||||||
Sends a request to the receiver to transition a player into
PLAYER_STATE_IDLE . | |||||||||||
Sends a request to the receiver to transition the last used player by this sender into
PLAYER_STATE_PLAYING . | |||||||||||
Sends a request to the receiver to transition a player into
PLAYER_STATE_PLAYING . | |||||||||||
Sends a request to the receiver to transition the last used player by this sender into
PLAYER_STATE_QUIT . | |||||||||||
Sends a request to the receiver to transition a player into
PLAYER_STATE_QUIT . | |||||||||||
Sends a request to the receiver to transition a player into
PLAYER_STATE_READY . | |||||||||||
Sends a request to the receiver to transition the last used player by this sender into
PLAYER_STATE_READY . | |||||||||||
Set the game manager client listener, which will trigger callbacks when the game
receives updates from the receiver device.
| |||||||||||
Sets the session label, which will be used as the prefix for log messages.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Gameplay indicating that the game is loading.
Gameplay state indicating that the game is paused.
Gameplay state indicating that the game is running.
Gameplay state indicating that the game is showing an information screen.
Unknown gameplay state.
Lobby state indicating that the lobby is closed and not accepting players.
Lobby state indicating that the lobby is open and accepting players to join.
Unknown lobby state.
Player state indicating that the player is connected to the receiver and available to join a game.
Player state indicating that the player is no longer connected to the receiver because of a network drop.
Player state indicating that the player is connected to the receiver, in the game , and idle.
Player state indicating that the player is connected to the receiver, in the game , and actively playing.
Player state indicating that the player has purposefully chosen to disconnect from the receiver.
Player state indicating that the player is connected to the receiver, and ready to enter the game.
Unknown player state.
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.
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.
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
.
Returns the current state of the game manager.
Returns | |
---|---|
GameManagerState |
Throws | |
---|---|
IllegalStateException |
If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
Constructs a new GameManagerClient using the provided GoogleApiClient. This is an async operation.
Parameters | |
---|---|
googleApiClient |
GoogleApiClient :
The API client with which to perform the operation. Must be connected
and contain the correct APIs. |
castSessionId |
String :
The session ID of the cast application session running on the receiver. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerInstanceResult> |
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.
|
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.
Returns | |
---|---|
String |
Throws | |
---|---|
IllegalStateException |
If there is no connection with the receiver device or if the Game Manager Client has been disposed. |
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 |
String :
The id of the controllable player sending this message. |
extraMessageData |
JSONObject :
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. |
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 |
JSONObject :
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. |
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
String :
The id of the controllable player sending this message. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
String :
The id of the controllable player to be affected by this state change. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
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 |
String :
The id of the controllable player to be affected by this state change. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
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 |
String :
The id of the controllable player to be affected by this state change. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
Sends a request to the receiver to transition a player into PLAYER_STATE_QUIT
.
Parameters | |
---|---|
playerId |
String :
The id of the controllable player to be affected by this state change. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
String :
The id of the controllable player to be affected by this state change. |
extraMessageData |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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. |
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 |
JSONObject :
Custom application-specific data to pass along with the request. |
Returns | |
---|---|
PendingResult<GameManagerClient.GameManagerResult> |
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:
Set the game manager client listener, which will trigger callbacks when the game receives updates from the receiver device.
Parameters | |
---|---|
listener |
GameManagerClient.Listener
|
See also:
Sets the session label, which will be used as the prefix for log messages.
Parameters | |
---|---|
sessionLabel |
String :
The prefix for logging messages. If null or an empty string is
passed no operation will be performed.
|