com.asdf.common
Class Game

java.lang.Object
  extended by com.asdf.common.Game
Direct Known Subclasses:
PokerGame, ServerSideHelloGameLogic, TestGamePlugin

public abstract class Game
extends java.lang.Object

Game interface. Game plugin developers implement abstract methods such as handleRequest and handleResponse to receive messages from clients. Plugins can send data using provided send methods.


Field Summary
 int age
          Tells us how many times this game has been checked for removal.
 
Constructor Summary
Game()
           
 
Method Summary
 java.lang.String[] columnNamesSync()
          Requests the game to return a list of columns this type of game wants to list in the game browser.
 GameListResponse.Games.Game descriptionSync()
          Requests the game to return a description of itself.
 void detailsSync(GameDetailsResponse a)
          Requests the game to return a description of itself.
abstract  void die()
          Offers the game a chance to notify all players and observers about the imminent destruction of this game.
 void dieSync()
          Offers the game a chance to notify all players and observers about the imminent destruction of this game.
 java.lang.String getAccountName(long sessionID)
          Get account name of the user.
 long getId()
          Getter for the game ID
 java.lang.String getName()
          Getter for the game's name.
 AccountType getUserType(long sessionID)
          Get type of the user.
 void handleRequestSync(long sessionID, GameRequest request)
          Handle incoming GameRequest.
 void handleResponseSync(long sessionID, GameResponse response)
          Handle incoming GameResponse.
 void initialize(Server server, long gameID, java.lang.String name)
          Only constructor.
 java.lang.String toString()
          toString method to ease debugging.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

age

public int age
Tells us how many times this game has been checked for removal.

Constructor Detail

Game

public Game()
Method Detail

handleRequestSync

public final void handleRequestSync(long sessionID,
                                    GameRequest request)
Handle incoming GameRequest. Responses may be sent with the send method. Game requests contain information the Game developer may define him self, and some basic information that every game is assumed to have, such as name, players, etc.. See protocol description for more information.

Parameters:
sessionID - Identifies session on which the message was received
request - GameRequest

descriptionSync

public final GameListResponse.Games.Game descriptionSync()
Requests the game to return a description of itself.


detailsSync

public final void detailsSync(GameDetailsResponse a)
Requests the game to return a description of itself.


columnNamesSync

public final java.lang.String[] columnNamesSync()
Requests the game to return a list of columns this type of game wants to list in the game browser.

Returns:
List of columns

handleResponseSync

public final void handleResponseSync(long sessionID,
                                     GameResponse response)
Handle incoming GameResponse.

Parameters:
sessionID - Identifies session on which the message was received
response - GameResponse

initialize

public final void initialize(Server server,
                             long gameID,
                             java.lang.String name)
Only constructor. Initializes member variables to given values.

Parameters:
server -
gameID -
name -

getId

public final long getId()
Getter for the game ID

Returns:
ID

getName

public final java.lang.String getName()
Getter for the game's name.

Returns:
Name of the game

getUserType

public AccountType getUserType(long sessionID)
Get type of the user.

Parameters:
sessionID -
Returns:
the AccountType

getAccountName

public java.lang.String getAccountName(long sessionID)
Get account name of the user.

Parameters:
sessionID -
Returns:
Name of the account or "Guest" if sessionID is not logged in with any account.

dieSync

public final void dieSync()
Offers the game a chance to notify all players and observers about the imminent destruction of this game. Synchronized version.


die

public abstract void die()
Offers the game a chance to notify all players and observers about the imminent destruction of this game.


toString

public java.lang.String toString()
toString method to ease debugging.

Overrides:
toString in class java.lang.Object
Returns:
Nice human readable description