Interface Info |
|---|
public interface PlayersClient Provides APIs for obtaining player information. |
Qualifier and Type | Method Name and Description |
|---|---|
| Obtains the Player object of the current player. | |
| Obtains the Player object of the current player. In the returned Player object, only getDisplayName, getOpenId, and getUnionId have return values. For other methods, a null value is returned. | |
getGamePlayer(boolean isRequirePlayerId) Obtains the Player object of the current player, in which both playerId and openId are returned. | |
Task<String> | Obtains the locally cached player ID of the current player. |
Task<Void> | savePlayerInfo(AppPlayerInfo appPlayerInfo) Saves a player's role information in the current game. CAUTION: This API will be deprecated. To save a player's role information, use the savePlayerRole method. |
Task<Void> | savePlayerRole(PlayerRoleInfo playerRoleInfo) Saves a player's role information in the current game. |
Method |
|---|
public Task<Player> getCurrentPlayer() Obtains the Player object of the current player. |
Returns
You need to set two callback listeners in Task returned by the API. In Task, you can obtain success data from OnSuccessListener, and request failure data from OnFailureListener. In OnFailureListener, you need to check whether the exception object is an ApiException instance. If so, use its getStatusCode() method to obtain the result code and then process the exception accordingly.
Method |
|---|
public Task<Player> getGamePlayer() Obtains the Player object of the current player. |
Returns
Type | Description |
|---|---|
Player object. In the returned Player object, only getDisplayName, getOpenId, and getUnionId have return values. For other methods, a null value is returned. |
You need to set two callback listeners in Task returned by the API. In Task, you can obtain success data from OnSuccessListener, and request failure data from OnFailureListener. In OnFailureListener, you need to check whether the exception object is an ApiException instance. If so, use its getStatusCode() method to obtain the result code and then process the exception accordingly.
Method |
|---|
public Task<Player> getGamePlayer(boolean isRequirePlayerId) Obtains the Player object of the current player. |
Parameters
Name | Description |
|---|---|
isRequirePlayerId | Indicates whether to return playerId.
NOTE: This parameter needs to be set only when playerId is replaced with openId. |
Returns
Type | Description |
|---|---|
Player object.
|
You need to set two callback listeners in Task returned by the API. In Task, you can obtain success data from OnSuccessListener, and request failure data from OnFailureListener. In OnFailureListener, you need to check whether the exception object is an ApiException instance. If so, use its getStatusCode() method to obtain the result code and then process the exception accordingly.
Method |
|---|
public Task<String> getCachePlayerId() Obtains the locally cached player ID of the current player. |
Returns
Type | Description |
|---|---|
Task<String> | Player ID. |
Method |
|---|
public Task<Void> savePlayerInfo(AppPlayerInfo appPlayerInfo) Stores the information about a player in a game, such as the level and region. |
Parameters
Name | Description |
|---|---|
Details about a player in a game. |
Returns
Type | Description |
|---|---|
Task<Void> | Save result. |
You need to set two callback listeners in Task returned by the API. In Task, you can obtain success data from OnSuccessListener, and request failure data from OnFailureListener. In OnFailureListener, you need to check whether the exception object is an ApiException instance. If so, use its getStatusCode() method to obtain the result code and then process the exception accordingly.
Method |
|---|
public Task<Void> savePlayerRole(PlayerRoleInfo playerRoleInfo) Stores the role information of a player in a game, such as the game server and role name. |
Parameters
Name | Description |
|---|---|
playerRoleInfo | Role information of a player in a game. For details, please refer to PlayerRoleInfo. |
Returns
Type | Description |
|---|---|
Task<Void> | Save result. |
You need to set two callback listeners in Task returned by the API. In Task, you can obtain success data from OnSuccessListener, and request failure data from OnFailureListener. In OnFailureListener, you need to check whether the exception object is an ApiException instance. If so, use its getStatusCode() method to obtain the result code and then process the exception accordingly.