RoomListener Events

Any Class can be deployed as a "Room" on the Server by implementing the RoomListener interface. An internal Room Object is created to take care of maintenance and management of the Room. The RoomListener Object need only worry about responding to events which are fired to create a powerful custom Room application.

onRoomInit

arguments

RoomServices - Reference to the RoomServices for this Room. Most of the RoomServices a Room will want to perform will be on itself in which case the reference should be saved for frequent use.

when fired

Once and only once when the Room is created.

onLogin

arguments

ClientServices - ClientServices for the Client that wants to login to the Room.
ArrayList - Any other Objects passed to validate the Client.

returns

true if the Client should be allowed to enter the Room
false otherwise

when fired

Whenever a request to login to the Room is made. If the method returns true the Client will be granted access and enter the Room.

onReceiveMessage

arguments

Message - The Message received.

when fired

Whenever a Message is received by the Room. Messages are guaranteed to be processed in the order they are received.

onAddClient

arguments

ClientServices - ClientServices for the Client that was added.

when fired

When a new Client joins the Room.

onRemoveClient

arguments

ClientServices - ClientServices for the Client that was removed.

when fired

When a Client leaves the Room.

onClientCountChange

arguments

int - The new number of Clients in the Room.

when fired

When the number of Clients in the Room changes. This method is called in addition to either onAddClient or onRemoveClient.

onRoomDie

arguments

when fired

Once and only once when the Room is being removed from the Server but before it is removed from the Room listing and any Clients inside are Removed from the Room. Resources used by the Room should be cleaned up here. This is the last event fired.

When a Room is killed that has Clients still in the Room then they are removed in a different manner than if they are removed from an active Room. In the case of Client removal because the Room was killed the onRemoveClient is called for each Client in the Room to give the Room a chance to perform any cleanup operations on the Clients before the Room is removed. However, onClientCountChange is NOT called nor is the Client actually removed from the list of Clients in the Room.