public class GameClient extends AndroidNonvisibleComponent implements Component, OnResumeListener, OnStopListener
form
ACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF
Constructor and Description |
---|
GameClient(ComponentContainer container)
Creates a new GameClient component.
|
Modifier and Type | Method and Description |
---|---|
void |
FunctionCompleted(java.lang.String functionName)
Indicates that a server request from a function call has
completed.
|
java.lang.String |
GameId()
Returns a string indicating the game name for this application.
|
void |
GameId(java.lang.String id)
Specifies a string indicating the family of the current game
instance.
|
void |
GetInstanceLists()
Updates the current InstancesJoined and InstancesInvited lists.
|
void |
GetMessages(java.lang.String type,
int count)
Retrieves messages of the specified type.
|
void |
GotMessage(java.lang.String type,
java.lang.String sender,
java.util.List<java.lang.Object> contents)
Indicates that a GetMessages call received a message.
|
void |
Info(java.lang.String message)
Indicates that something has occurred which the player should be
somehow informed of.
|
void |
Initialize()
Ensures that the GameId was set by the game creator.
|
java.lang.String |
InstanceId()
Returns the game instance id.
|
void |
InstanceIdChanged(java.lang.String instanceId)
Indicates that InstanceId has changed due to the creation of a
new instance or setting the InstanceId.
|
void |
Invite(java.lang.String playerEmail)
Invites a player to this game instance.
|
void |
Invited(java.lang.String instanceId)
Indicates a user has been invited to this game instance by
another player.
|
java.util.List<java.lang.String> |
InvitedInstances()
Returns the set of game instances to which this player has been
invited but has not yet joined.
|
java.util.List<java.lang.String> |
JoinedInstances()
Returns the set of game instances in which this player is
participating.
|
java.lang.String |
Leader()
Returns the game's leader.
|
void |
LeaveInstance()
Requests to leave the current instance.
|
void |
MakeNewInstance(java.lang.String instanceId,
boolean makePublic)
Creates a new game instance.
|
void |
NewInstanceMade(java.lang.String instanceId)
Indicates this game instance was created as specified via
MakeNewInstance.
|
void |
NewLeader(java.lang.String playerId)
Indicates this game instance has a new leader.
|
void |
onResume()
Called automatically by the operating system.
|
void |
onStop()
Called automatically by the operating system.
|
void |
PlayerJoined(java.lang.String playerId)
Indicates that a player has joined this game instance.
|
void |
PlayerLeft(java.lang.String playerId)
Indicates that a player has left this game instance.
|
java.util.List<java.lang.String> |
Players()
Returns the current set of players for this game instance.
|
java.util.List<java.lang.String> |
PublicInstances()
Returns the set of game instances that have been marked public.
|
void |
SendMessage(java.lang.String type,
YailList recipients,
YailList contents)
Creates a new message and sends it to the stated recipients.
|
void |
ServerCommand(java.lang.String command,
YailList arguments)
Submits a command to the game server.
|
void |
ServerCommandFailure(java.lang.String command,
YailList arguments)
Indicates that an attempt to complete a server command failed on
the server.
|
void |
ServerCommandSuccess(java.lang.String command,
java.util.List<java.lang.Object> response)
Indicates that a ServerCommand completed.
|
java.lang.String |
ServiceUrl()
The URL of the game server.
|
void |
ServiceURL(java.lang.String url)
Set the URL of the game server.
|
void |
SetInstance(java.lang.String instanceId)
Specifies the game instance id.
|
void |
SetLeader(java.lang.String playerEmail)
Specifies the game's leader.
|
java.lang.String |
UserEmailAddress()
Returns the registered email address that is being used as the
player id for this game client.
|
void |
UserEmailAddress(java.lang.String emailAddress)
Changes the player of this game by changing the email address
used to communicate with the server.
|
void |
UserEmailAddressSet(java.lang.String emailAddress)
Indicates that the user email address property has been
successfully set.
|
void |
WebServiceError(java.lang.String functionName,
java.lang.String message)
Indicates that the attempt to communicate with the web service
resulted in an error.
|
getDispatchDelegate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDispatchDelegate
public GameClient(ComponentContainer container)
container
- the Form that this component is contained in.public java.lang.String GameId()
public void GameId(java.lang.String id)
public java.lang.String InstanceId()
public java.util.List<java.lang.String> InvitedInstances()
GetInstanceLists()
.public java.util.List<java.lang.String> JoinedInstances()
GetInstanceLists()
.public java.lang.String Leader()
public java.util.List<java.lang.String> Players()
public java.util.List<java.lang.String> PublicInstances()
GetInstanceLists()
.public java.lang.String ServiceUrl()
public void ServiceURL(java.lang.String url)
url
- The URL (include initial http://).public java.lang.String UserEmailAddress()
public void UserEmailAddress(java.lang.String emailAddress)
emailAddress
- The email address to set the current player
id to.public void FunctionCompleted(java.lang.String functionName)
functionName
- The name of the App Inventor function that
finished.public void Initialize()
public void GotMessage(java.lang.String type, java.lang.String sender, java.util.List<java.lang.Object> contents)
type
- The type of the message received.contents
- The message's contents. Consists of a list
nested to arbitrary depth that includes string, boolean and
number values.public void InstanceIdChanged(java.lang.String instanceId)
instanceId
- The id of the instance the player is now in.public void Invited(java.lang.String instanceId)
instanceId
- The id of the new game instance.public void NewLeader(java.lang.String playerId)
playerId
- The email address of the new leader.public void NewInstanceMade(java.lang.String instanceId)
instanceId
- The id of the newly created game instance.public void PlayerJoined(java.lang.String playerId)
playerId
- The email address of the new player.public void PlayerLeft(java.lang.String playerId)
playerId
- The email address of the player that left.public void ServerCommandFailure(java.lang.String command, YailList arguments)
command
- The command requested.arguments
- The arguments sent to the command.public void ServerCommandSuccess(java.lang.String command, java.util.List<java.lang.Object> response)
command
- The key for the command that resulted in this
response.response
- The server response. This consists of a list
nested to arbitrary depth that includes string, boolean and
number values.public void UserEmailAddressSet(java.lang.String emailAddress)
public void Info(java.lang.String message)
message
- the message.public void WebServiceError(java.lang.String functionName, java.lang.String message)
functionName
- The name of the function call that caused this
error.message
- the error messagepublic void GetInstanceLists()
public void GetMessages(java.lang.String type, int count)
type
- The type of message to retrieve. If the empty string
is used as the message type then all message types will be
requested.count
- The maximum number of messages to retrieve. This
should be an integer from 1 to 1000.public void Invite(java.lang.String playerEmail)
playerEmail
- a string containing the email address of the
player to become leader. The email should be in one of the
following formats:public void LeaveInstance()
public void MakeNewInstance(java.lang.String instanceId, boolean makePublic)
instanceId
- A string to use as for the instance
id. If no other instance exists with this id, the new instance
will have this id. However, since the id must be unique, if
another instance exists with the same one, then a number
will be appended to the end of this prefix.makePublic
- A boolean indicating whether or not the
instance should be publicly viewable and able to be joined by
anyone.public void SendMessage(java.lang.String type, YailList recipients, YailList contents)
type
- A "key" for the message. This identifies the type of
message so that when other players receive the message they know
how to properly handle it.recipients
- If set to an empty list, the server will send
this message with a blank set of recipients, meaning that all
players in the instance are able to retrieve it. To limit the
message receipt to a single person or a group of people,
recipients should be a list of the email addresses of the people
meant to receive the message. Each email should be in one of the
following formats:contents
- the contents of the message. This can be any
AppInventor data value.public void ServerCommand(java.lang.String command, YailList arguments)
command
- The name of the server command.arguments
- The arguments to pass to the server to specify
how to execute the command.public void SetInstance(java.lang.String instanceId)
instanceId
- the name of the game instance to join.public void SetLeader(java.lang.String playerEmail)
playerEmail
- a string containing the email address of the
player to become leader. The email should be in one of the
following formats:
public void onResume()
onResume
in interface OnResumeListener
public void onStop()
onStop
in interface OnStopListener