PlayerIO

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

Android Client Reference

Android  class documentationClass Multiplayer

Namespace: com.playerio
Language: Java

The Multiplayer service

Here is an example of joining a multiplayer room and listening to all messages:

Methods

 
public void
createJoinRoom (String roomId, String roomType, boolean visible, Map<String,String> roomData, Map<String,String> joinData, Callback<Connection> callback)

Creates a multiplayer room (if it does not exist already) and joins it.

public void
createRoom (String roomId, String roomType, boolean visible, Map<String,String> roomData, Callback<String> callback)

Create a multiplayer room on the Player.IO infrastructure.

public void
joinRoom (String roomId, Map<String,String> joinData, Callback<Connection> callback)

Join a running multiplayer room.

public void
listRooms (String roomType, Map<String,String> searchCriteria, int resultLimit, int resultOffset, Callback<RoomInfo[]> callback)

List the currently running multiplayer rooms.

public void
setDevelopmentServer (ServerEndpoint developmentServer)

If not null, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.

public void
setUseSecureConnections (boolean value)

If true, the multiplayer connections will be encrypted using TLS/SSL.

Multiplayer.createJoinRoom

public void
createJoinRoom (String roomId, String roomType, boolean visible, Map<String,String> roomData, Map<String,String> joinData, Callback<Connection> callback)

Creates a multiplayer room (if it does not exist already) and joins it.

Arguments

String roomId
The id of the room you wish to create/join.
String roomType
The name of the room type you wish to run the room as. This value should match one of the [RoomType(...)] attributes of your uploaded code. A room type of 'bounce' is always available.
boolean visible
If the room doesn't exist: Should the room be visible when listing rooms with GetRooms upon creation?
Map<String,String> roomData
If the room doesn't exist: The data to initialize the room with upon creation.
Map<String,String> joinData
Data to send to the room with additional information about the join.
Callback<Connection> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

Multiplayer.createRoom

public void
createRoom (String roomId, String roomType, boolean visible, Map<String,String> roomData, Callback<String> callback)

Create a multiplayer room on the Player.IO infrastructure.

Arguments

String roomId
The id you wish to assign to your new room - You can use this to connect to the specific room later as long as it still exists.
String roomType
The name of the room type you wish to run the room as. This value should match one of the [RoomType(...)] attributes of your uploaded code. A room type of 'bounce' is always available.
boolean visible
Should the room be visible when listing rooms with GetRooms or not?
Map<String,String> roomData
The data to initialize the room with, this can be read with ListRooms and changed from the serverside.
Callback<String> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

Multiplayer.joinRoom

public void
joinRoom (String roomId, Map<String,String> joinData, Callback<Connection> callback)

Join a running multiplayer room.

Arguments

String roomId
The id of the room you wish to connect to.
Map<String,String> joinData
Data to send to the room with additional information about the join.
Callback<Connection> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

Multiplayer.listRooms

public void
listRooms (String roomType, Map<String,String> searchCriteria, int resultLimit, int resultOffset, Callback<RoomInfo[]> callback)

List the currently running multiplayer rooms.

Arguments

String roomType
The type of room you wish to list.
Map<String,String> searchCriteria
Only rooms with the same values in their roomdata will be returned.
int resultLimit
The maximum amount of rooms you want to receive. Use 0 for 'as many as possible'.
int resultOffset
The offset into the list you wish to start listing at.
Callback<RoomInfo[]> callback
The callback that will be used to return results. On success its onSuccess method will be called, otherwise its onError method.

Throws

PlayerIOError

Multiplayer.setDevelopmentServer

public void
setDevelopmentServer (ServerEndpoint developmentServer)

If not null, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.

Arguments

ServerEndpoint developmentServer

Multiplayer.setUseSecureConnections

public void
setUseSecureConnections (boolean value)

If true, the multiplayer connections will be encrypted using TLS/SSL.

Arguments

boolean value