PlayerIO

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

Android Client Reference

Android  class documentationClass Connection

Namespace: com.playerio
Language: Java

A connection into a running Player.IO multiplayer room.

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

Methods

 
public void
addDisconnectListener (DisconnectListener listener)

Add a disconnect listener to this connection.

public void
addMessageListener (String type, MessageListener listener)

Add a message listener to this connection.

public void
disconnect ()

Disconnect from the game room

public boolean
isConnected ()

Is the connection currently connected to a remote host?

public void
send (String type, Object... parameters)

Send a message to the connected client without first having to construct a Message object.

public void
send (Message msg)

Send a message to the room

Connection.addDisconnectListener

public void
addDisconnectListener (DisconnectListener listener)

Add a disconnect listener to this connection.

Arguments

DisconnectListener listener
The listener to add.

Connection.addMessageListener

public void
addMessageListener (String type, MessageListener listener)

Add a message listener to this connection.

Arguments

String type
Specify the type of messages that this listener should receive, or '*' for a catch-all listener.
MessageListener listener
The listener to add.

Connection.disconnect

public void
disconnect ()

Disconnect from the game room

Connection.isConnected

public boolean
isConnected ()

Is the connection currently connected to a remote host?

Connection.send

public void
send (String type, Object... parameters)

Send a message to the connected client without first having to construct a Message object.

Arguments

String type
The type of message to send.
Object... parameters
The data to put in the message to send.

Connection.send

public void
send (Message msg)

Send a message to the room

Arguments

Message msg
The message to send