PlayerIO

The fastest way to build online games without breaking a sweat.

Android Client Reference

Android  class documentationClass 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 (long value)

Add a long to the message payload.

public void
add (double value)

Add a double to the message payload.

public void
add (boolean value)

Add a boolean to the message payload.

public void
add (byte[] value)

Add a byte[] to the message payload.

public void
add (float value)

Add a float to the message payload.

public void
add (Object... parameters)

Add multiple pieces of data to the message in one go.

public void
add (int value)

Add an int to the message payload.

public void
add (String value)

Add a String to the message payload.

public void
addUInt (int value)

Add an uint to the message payload.

public void
addULong (long value)

Add a ulong to the message payload.

public static Message
create (String type, Object... parameters)

Create a new Message

public boolean
getBoolean (int index)

Gets the boolean at the given index

public byte[]
getByteArray (int index)

Gets the byte[] at the given index

public double
getDouble (int index)

Gets the double at the given index

public float
getFloat (int index)

Gets the float at the given index

public int
getInt (int index)

Gets the int at the given index

public int
getInteger (int index)

Gets the int at the given index

public long
getLong (int index)

Gets the long at the given index

public String
getString (int index)

Gets the String at the given index

public String
getType ()

The type of the Message.

public int
getUInt (int index)

Gets the uint at the given index

public long
getULong (int index)

Gets the ulong at the given index

public int
getUnsignedInteger (int index)

Gets the uint at the given index

public long
getUnsignedLong (int index)

Gets the ulong at the given index

public int
size ()

Get the number of objects in this Message.

Message.add

public void
add (long value)

Add a long to the message payload.

Arguments

long value

Message.add

public void
add (double value)

Add a double to the message payload.

Arguments

double value

Message.add

public void
add (boolean value)

Add a boolean to the message payload.

Arguments

boolean value

Message.add

public void
add (byte[] value)

Add a byte[] to the message payload.

Arguments

byte[] value

Message.add

public void
add (float value)

Add a float to the message payload.

Arguments

float value

Message.add

public void
add (Object... parameters)

Add multiple pieces of data to the message in one go.

Arguments

Object... parameters

Message.add

public void
add (int value)

Add an int to the message payload.

Arguments

int value

Message.add

public void
add (String value)

Add a String to the message payload.

Arguments

String value

Message.addUInt

public void
addUInt (int value)

Add an uint to the message payload.

Arguments

int value

Message.addULong

public void
addULong (long value)

Add a ulong to the message payload.

Arguments

long value

Message.create

public static Message
create (String type, Object... parameters)

Create a new Message

Arguments

String type
The type of message to create.
Object... parameters
An optional list of data to add to the message.

Message.getBoolean

public boolean
getBoolean (int index)

Gets the boolean at the given index

Arguments

int index

Message.getByteArray

public byte[]
getByteArray (int index)

Gets the byte[] at the given index

Arguments

int index

Message.getDouble

public double
getDouble (int index)

Gets the double at the given index

Arguments

int index

Message.getFloat

public float
getFloat (int index)

Gets the float at the given index

Arguments

int index

Message.getInt

public int
getInt (int index)

Gets the int at the given index

Arguments

int index

Message.getInteger

public int
getInteger (int index)

Gets the int at the given index

Arguments

int index

Message.getLong

public long
getLong (int index)

Gets the long at the given index

Arguments

int index

Message.getString

public String
getString (int index)

Gets the String at the given index

Arguments

int index

Message.getType

public String
getType ()

The type of the Message.

Message.getUInt

public int
getUInt (int index)

Gets the uint at the given index

Arguments

int index

Message.getULong

public long
getULong (int index)

Gets the ulong at the given index

Arguments

int index

Message.getUnsignedInteger

public int
getUnsignedInteger (int index)

Gets the uint at the given index

Arguments

int index

Message.getUnsignedLong

public long
getUnsignedLong (int index)

Gets the ulong at the given index

Arguments

int index

Message.size

public int
size ()

Get the number of objects in this Message.