Android Client Reference
Class Message
Namespace: com.playerio
Language: Java
Represents a message sent between client and server.
A message consists of a string type, and a payload of zero or more typed parameters.
For example here we create a simple message that we send to the server indicating that this player is ready:
Usually, it's much easier to simply use the convenience methods:
You can also build up messages as you go, if you don't know the exact payload until runtime.
In this example, imagine the player has multiple pieces and we send in the list of moves this player wants to do in a single turn.
Methods | |||
---|---|---|---|
public void |
Add a long to the message payload. |
||
public void |
Add a double to the message payload. |
||
public void |
Add a boolean to the message payload. |
||
public void |
Add a byte[] to the message payload. |
||
public void |
Add a float to the message payload. |
||
public void |
Add multiple pieces of data to the message in one go. |
||
public void |
Add an int to the message payload. |
||
public void |
Add a String to the message payload. |
||
public void |
Add an uint to the message payload. |
||
public void |
Add a ulong to the message payload. |
||
public static Message |
Create a new Message |
||
public boolean |
Gets the boolean at the given index |
||
public byte[] |
Gets the byte[] at the given index |
||
public double |
Gets the double at the given index |
||
public float |
Gets the float at the given index |
||
public int |
Gets the int at the given index |
||
public int |
Gets the int at the given index |
||
public long |
Gets the long at the given index |
||
public String |
Gets the String at the given index |
||
public String |
The type of the Message. |
||
public int |
Gets the uint at the given index |
||
public long |
Gets the ulong at the given index |
||
public int |
Gets the uint at the given index |
||
public long |
Gets the ulong at the given index |
||
public int |
Get the number of objects in this Message. |
Message.add
public void |
|
Add a long to the message payload.
Arguments
long | value |
Message.add
public void |
|
Add a double to the message payload.
Arguments
double | value |
Message.add
public void |
|
Add a boolean to the message payload.
Arguments
boolean | value |
Message.add
public void |
|
Add a byte[] to the message payload.
Arguments
byte[] | value |
Message.add
public void |
|
Add a float to the message payload.
Arguments
float | value |
Message.add
public void |
|
Add multiple pieces of data to the message in one go.
Arguments
Object... | parameters |
Message.add
public void |
|
Add an int to the message payload.
Arguments
int | value |
Message.add
public void |
|
Add a String to the message payload.
Arguments
String | value |
Message.addUInt
public void |
|
Add an uint to the message payload.
Arguments
int | value |
Message.addULong
public void |
|
Add a ulong to the message payload.
Arguments
long | value |
Message.create
public static Message |
|
Create a new Message
Arguments
String | type |
Object... | parameters |
Message.getBoolean
public boolean |
|
Gets the boolean at the given index
Arguments
int | index |
Message.getByteArray
public byte[] |
|
Gets the byte[] at the given index
Arguments
int | index |
Message.getDouble
public double |
|
Gets the double at the given index
Arguments
int | index |
Message.getFloat
public float |
|
Gets the float at the given index
Arguments
int | index |
Message.getInt
public int |
|
Gets the int at the given index
Arguments
int | index |
Message.getInteger
public int |
|
Gets the int at the given index
Arguments
int | index |
Message.getLong
public long |
|
Gets the long at the given index
Arguments
int | index |
Message.getString
public String |
|
Gets the String at the given index
Arguments
int | index |
Message.getType
public String |
|
The type of the Message.
Message.getUInt
public int |
|
Gets the uint at the given index
Arguments
int | index |
Message.getULong
public long |
|
Gets the ulong at the given index
Arguments
int | index |
Message.getUnsignedInteger
public int |
|
Gets the uint at the given index
Arguments
int | index |
Message.getUnsignedLong
public long |
|
Gets the ulong at the given index
Arguments
int | index |
Message.size
public int |
|
Get the number of objects in this Message.