Glomus.Server
Class Server

java.lang.Object
  extended by Glomus.Server.Server

public class Server
extends java.lang.Object

The Server class listens for requests on a common port and processes them, adding players to games or creating new games entirely. Games are separate threads, and once they are ready, the Server launches them off, from which point an instance of the GameBoard class takes care of everything necessary to run a game.

The Server makes use of the common protocol shared between client and server as encapsulated by the Protocol class, refer to it for more information

See Also:
Protocol, GameBoard

Field Summary
static boolean DEBUGGING
          A signal to all classes that make up the server, whether or not we are running in debug mode such that all messages received are printed to standard out
static int DEFAULT_PORT
          The Port the clients and server will agree to communicate on
protected static int GAME_TIMEOUT
          The amount of time (in milliseconds) to wait before starting up a pending game.
static int REPLACEMENT_PORT
          The Port at which the GameBoard class will look for replacement players when it needs them
static java.net.ServerSocket REPLACEMENT_SOCKET
          The ServerSocket on which to listen for replacement players join requests.
static int TIMEOUT
          The amount of time to wait (in milliseconds) before the Server raises a TimeoutException and kicks an AI player out for taking too long to take their turn
 
Constructor Summary
Server()
           
 
Method Summary
static void main(java.lang.String[] args)
          The main method runs in a simple loop forever, waiting for connections to the messaging port (DEFAULT_PORT) to request a new game, or to join a game.
static void signalDone(java.lang.String name)
          Called by a launched game to signify that it has finished its execution and is now shutting down; This causes the Server to free up the specified game name for future use by other new games
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
The Port the clients and server will agree to communicate on

See Also:
Constant Field Values

REPLACEMENT_PORT

public static final int REPLACEMENT_PORT
The Port at which the GameBoard class will look for replacement players when it needs them

See Also:
Constant Field Values

REPLACEMENT_SOCKET

public static java.net.ServerSocket REPLACEMENT_SOCKET
The ServerSocket on which to listen for replacement players join requests. GameBoards reference this and listen on it, accepting connections and using them as replacement players


TIMEOUT

public static int TIMEOUT
The amount of time to wait (in milliseconds) before the Server raises a TimeoutException and kicks an AI player out for taking too long to take their turn


GAME_TIMEOUT

protected static final int GAME_TIMEOUT
The amount of time (in milliseconds) to wait before starting up a pending game. (The default is five minutes)

See Also:
Constant Field Values

DEBUGGING

public static boolean DEBUGGING
A signal to all classes that make up the server, whether or not we are running in debug mode such that all messages received are printed to standard out

Constructor Detail

Server

public Server()
Method Detail

main

public static void main(java.lang.String[] args)
The main method runs in a simple loop forever, waiting for connections to the messaging port (DEFAULT_PORT) to request a new game, or to join a game. It wraps a Player around the received collection, puts the player in a game, and goes back to waiting


signalDone

public static void signalDone(java.lang.String name)
Called by a launched game to signify that it has finished its execution and is now shutting down; This causes the Server to free up the specified game name for future use by other new games

Parameters:
name - The name of the game to finalize