All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class game.GameServer

java.lang.Object
   |
   +----game.GameServer

public class GameServer
extends Object
implements HandlerListener, GameLinkConstants
The GameServer class is the main class of the server side of the multi-game. It contains the main method which is used to boot up the server. [FINISH ME]


Variable Index

 o clientHandlers
List of Clients currently connected.
 o currentId
Current id attributed to new games.
 o debug
if true, enables the printing of debug informations on the console.
 o gameFactory
[DESCRIBE ME]
 o gameHandlers
Set of all games currently running.
 o name
The name of this GameServer.
 o port
I/O Port the server will listen to.
 o props
Properties for this GameServer.
 o shouldQuit
[DESCRIBE ME]

Constructor Index

 o GameServer()
Creates a new GameServer

Method Index

 o addGame(Game)
Adds a new game in the server, creating the appropriate GameServer, with the specified game id.
 o getAllGameInfos()
Returns a Vector of GameInfo informations for all games in the server, including new and running games.
 o getGame(Object)
Returns the game corresponding to the given id.
 o getName()
Returns the name of this GameServer
 o getNewId()
Returns a new unique Id for a new game beeing created.
 o getPort()
Returns the I/O port the server will listen to.
 o handlerHasChanged(Handler)
 o handlerLostConnection(Handler)
 o main(String[])
The GameServer entry point.
 o removeGame(GameHandler)
Remove the specified game from the set of games runned by the server.
 o removeHandler(ClientHandler)
Removes the specified ClientHandler from the set of running client handlers.
 o removePlayerFromGame(Player, GameHandler)
Removes the specified player from the given game.
 o sendToClients(LinkFrame)
Sends the given frame to all currently connected clients.
 o waitForConnections()
[DESCRIBE ME]

Variables

 o gameHandlers
 Hashtable gameHandlers
Set of all games currently running.

 o gameFactory
 GameFactory gameFactory
[DESCRIBE ME]

 o name
 String name
The name of this GameServer.

 o port
 int port
I/O Port the server will listen to.

 o props
 Properties props
Properties for this GameServer.

 o currentId
 Integer currentId
Current id attributed to new games.

 o debug
 boolean debug
if true, enables the printing of debug informations on the console.

 o shouldQuit
 boolean shouldQuit
[DESCRIBE ME]

 o clientHandlers
 Vector clientHandlers
List of Clients currently connected.

Constructors

 o GameServer
 public GameServer()
Creates a new GameServer

Methods

 o getName
 public String getName()
Returns the name of this GameServer

 o getPort
 public int getPort()
Returns the I/O port the server will listen to.

 o getAllGameInfos
 public Vector getAllGameInfos()
Returns a Vector of GameInfo informations for all games in the server, including new and running games.

 o addGame
 public GameHandler addGame(Game game)
Adds a new game in the server, creating the appropriate GameServer, with the specified game id.

Parameters:
id - the id that has to be associated with game
game - the game to be added into the server
Returns:
the new GameHandler created on top of game.
 o getGame
 public GameHandler getGame(Object id)
Returns the game corresponding to the given id. The game is either a currently running game, in which case it is returned directly, or a new game. In this latter case the game is created and returned. The object returned is actually a GameHandler which is used to hold and run games in the server.

Parameters:
id - the id of the game requested.
Returns:
the game retrieved or created, or null if the game cannot be found.
 o removeGame
 public void removeGame(GameHandler handler)
Remove the specified game from the set of games runned by the server.

Parameters:
handler - the game to be removed from the server.
 o removePlayerFromGame
 public void removePlayerFromGame(Player player,
                                  GameHandler handler)
Removes the specified player from the given game. If this makes the game terminate, then remove the game from the server.

Parameters:
player - the player to remove from the game
handler - the GameHandler from which to remove the player.
 o getNewId
 public Integer getNewId()
Returns a new unique Id for a new game beeing created.

 o handlerHasChanged
 public void handlerHasChanged(Handler handler)
 o handlerLostConnection
 public void handlerLostConnection(Handler handler)
 o sendToClients
 public void sendToClients(LinkFrame frame)
Sends the given frame to all currently connected clients. The lastly added client will be messaged first.

Parameters:
frame - the frame to send to all clients.
 o main
 public static void main(String args[])
The GameServer entry point. [FINISH ME]

 o waitForConnections
 public void waitForConnections()
[DESCRIBE ME]

 o removeHandler
 public void removeHandler(ClientHandler handler)
Removes the specified ClientHandler from the set of running client handlers.

Parameters:
handler - the handler to remove from the set.

All Packages  Class Hierarchy  This Package  Previous  Next  Index