Realtime Turn Based Gaming
- distributed timer management
- distributed turn management
- distributed state management
All the management is done on the server side by AppWarp cloud when a turn based room is created. Notifications are sent to clients when a move is made or a player’s turn expires. Player’s turns are assigned in the order in which the room is joined. Developers have the flexibility of defining the maximum turn time to be allotted for each turn. If a player fails to send its move in the allotted time or leaves the room, its turn expires and the turn is passed to the next player. All the timer and turn management logic is implemented on the server by AppWarp and clients simply need to react to the events.
Sending a move is simple and developers can send any string data up to 500 characters.
Here is a summary of the APIs (Java for example below – similar APIs are available for all supported platforms)
public void createTurnRoom(String name, String owner, int maxUsers, Hashtable
tableProperties, int turnTime)
This is similar to the creation of dynamic rooms with the addition of a turn time. Once the room has two or more players joined, it will start sending notifications regarding moves and turn changes.
public void sendMove(String moveData)
This API is used to send the player’s move and will result in onMoveCompleted notification to all the subscribed users of the room.
public void onMoveCompleted(MoveEvent moveEvent);
This is the event raised on the registered notification listener when a player successfully makes a move or a turn expires. The move event object contains the following information
- moveData – The associated move data.
- sender – The sender of the move.
- RoomId – The id of the room in which the move was sent
- nextTurn – The username of the user whose turn it is now