heurgame
Class GameServer

java.lang.Object
  extended byheurgame.GameServer
All Implemented Interfaces:
java.lang.Runnable

public class GameServer
extends java.lang.Object
implements java.lang.Runnable

Author:
David Kaplin The role of the GameServer is to abstract away the plumbing that is necessary for a socket mediated mode of communication. The GameServer also acts as a Facade hiding the interface of Game and Referee from some parts of the user interface. Hopefully this class will remove the nead for more plumbing.

Field Summary
protected  boolean active
           
 
Constructor Summary
GameServer(java.lang.String hostname, int port, Game thisGame, Referee official)
          Constructs a new GameServer
 
Method Summary
 java.lang.String getGameName()
           
 int getMinimumPlayers()
           
 java.lang.String getServerAddress()
           
 boolean isActive()
           
 void makeHuClient(java.lang.String name)
          Delegates the creation of a HuClient, a human client to the server.
 void reorderPlayers(PlayerToken[] newOrder)
          Called to reorder the current connected players
 void reset()
          Called to disconnect all connected players from the game.
 void run()
          Actual guts of the Server code.
 void stopServer()
          Causes the Server spinloop to gracefully halt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

active

protected volatile boolean active
Constructor Detail

GameServer

public GameServer(java.lang.String hostname,
                  int port,
                  Game thisGame,
                  Referee official)
Constructs a new GameServer

Parameters:
hostname - for the server to bind
port - also for binding
thisGame - allowing the proper construction of Game Specific HuClients and PlayerProxies
official - Referees are involved in all player related transactions
Method Detail

run

public void run()
Actual guts of the Server code. This is meant to be stuffed inside of a thread!

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

reorderPlayers

public void reorderPlayers(PlayerToken[] newOrder)
Called to reorder the current connected players

Parameters:
newOrder - New Established Order

reset

public void reset()
Called to disconnect all connected players from the game.


makeHuClient

public void makeHuClient(java.lang.String name)
Delegates the creation of a HuClient, a human client to the server.

Parameters:
name - of the client

getMinimumPlayers

public int getMinimumPlayers()

getServerAddress

public java.lang.String getServerAddress()
Returns:
String representing the ip address of the server and its port.

getGameName

public java.lang.String getGameName()
Returns:
Name of the game.

isActive

public boolean isActive()

stopServer

public void stopServer()
Causes the Server spinloop to gracefully halt.