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]
-
clientHandlers
-
List of Clients currently connected.
-
currentId
- Current id attributed to new games.
-
debug
- if true, enables the printing of debug informations on the console.
-
gameFactory
- [DESCRIBE ME]
-
gameHandlers
- Set of all games currently running.
-
name
- The name of this GameServer.
-
port
- I/O Port the server will listen to.
-
props
- Properties for this GameServer.
-
shouldQuit
- [DESCRIBE ME]
-
GameServer()
- Creates a new GameServer
-
addGame(Game)
- Adds a new game in the server, creating the appropriate
GameServer
, with the specified game id.
-
getAllGameInfos()
- Returns a Vector of
GameInfo
informations for
all games in the server, including new and running games.
-
getGame(Object)
- Returns the game corresponding to the given id.
-
getName()
- Returns the name of this GameServer
-
getNewId()
- Returns a new unique Id for a new game beeing created.
-
getPort()
- Returns the I/O port the server will listen to.
-
handlerHasChanged(Handler)
-
-
handlerLostConnection(Handler)
-
-
main(String[])
- The GameServer entry point.
-
removeGame(GameHandler)
- Remove the specified game from the set of games runned by the
server.
-
removeHandler(ClientHandler)
- Removes the specified
ClientHandler
from the set of
running client handlers.
-
removePlayerFromGame(Player, GameHandler)
- Removes the specified player from the given game.
-
sendToClients(LinkFrame)
- Sends the given frame to all currently connected clients.
-
waitForConnections()
- [DESCRIBE ME]
gameHandlers
Hashtable gameHandlers
- Set of all games currently running.
gameFactory
GameFactory gameFactory
- [DESCRIBE ME]
name
String name
- The name of this GameServer.
port
int port
- I/O Port the server will listen to.
props
Properties props
- Properties for this GameServer.
currentId
Integer currentId
- Current id attributed to new games.
debug
boolean debug
- if true, enables the printing of debug informations on the console.
shouldQuit
boolean shouldQuit
- [DESCRIBE ME]
clientHandlers
Vector clientHandlers
- List of Clients currently connected.
GameServer
public GameServer()
- Creates a new GameServer
getName
public String getName()
- Returns the name of this GameServer
getPort
public int getPort()
- Returns the I/O port the server will listen to.
getAllGameInfos
public Vector getAllGameInfos()
- Returns a Vector of
GameInfo
informations for
all games in the server, including new and running games.
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.
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.
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.
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.
getNewId
public Integer getNewId()
- Returns a new unique Id for a new game beeing created.
handlerHasChanged
public void handlerHasChanged(Handler handler)
handlerLostConnection
public void handlerLostConnection(Handler handler)
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.
main
public static void main(String args[])
- The GameServer entry point. [FINISH ME]
waitForConnections
public void waitForConnections()
- [DESCRIBE ME]
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