|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectglassfrog.server.Room
public class Room
The Room class is the class that will handle all of the game code. The rooms consist of Players and a Dealer. The room is responsible for handleing all the connections to the Players, The room takes connections until it is "full" then it will start the game with the given specifications. After the game is started, the dealer will then handle all of the game logic, and the Room will be responsible for message passing to the players. Essentially, the Dealer handles the gamestates, and then the room is responsible for sending an action request to the proper player. The response is then sent back to the Dealer. Once the game is over, the room will be shutdown, or restarted, depending on specifications of the room.
Nested Class Summary | |
---|---|
private class |
Room.RoomConnectionHandler
An Inner Class used to handle incoming connections to the room. |
Field Summary | |
---|---|
private boolean |
alive
|
private Dealer |
dealer
|
private java.io.FileWriter |
errorLog
|
private java.io.BufferedWriter |
errorLogWriter
|
private Gamedef |
gamedef
|
private java.lang.String |
name
|
private int |
numHands
|
private int |
playerCount
|
private java.util.LinkedList<Player> |
players
|
private int |
port
|
private static int |
PORTBASE
|
private static int |
ROOM_TIMEOUT
|
private java.io.FileWriter |
roomLog
|
private java.io.BufferedWriter |
roomLogWriter
|
private boolean |
runOnce
|
private static boolean |
SAVE_FLAG
|
private int |
seed
|
private java.net.ServerSocket |
serverSocket
|
private static int |
TIMEOUT
|
Constructor Summary | |
---|---|
Room(java.lang.String name,
int hands,
Gamedef gamedef,
int seed)
Starts up a Room. |
Method Summary | |
---|---|
java.lang.String |
getName()
Getter for the room's name |
int |
getPort()
Return the port the room is running on |
java.lang.String |
getStatus()
Return the current status of the room. |
private void |
initLogging()
Initialize the logs for the game. |
private void |
initServerSocket()
Set up the server socket. |
boolean |
isAlive()
Check to see if the room is still alive. |
private void |
listen()
Listen for incoming connections. |
private static void |
loadSettings()
|
void |
logError(java.lang.Exception ex)
Utility for logging an error message to the errorLogger |
void |
logInfo(java.lang.String info,
boolean toOut)
Log a gamesate to the roomLogger |
void |
logWarning(java.lang.String warningMessage)
Utility for logging a warning message to the errorLogger |
void |
run()
Calls the listen method to wait for connections. |
private void |
saveDealer()
Save the instance of the dealer to file for reloading of the game |
void |
shutdown()
Shutdown a room via request from the server or game is over |
private void |
startNewDealer()
Load up a new dealer and save it for the first time. |
java.lang.String |
toString()
Return a human readable, parser friendly : delimited representation of the Room's info |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String name
private Gamedef gamedef
private Dealer dealer
private java.net.ServerSocket serverSocket
private java.util.LinkedList<Player> players
private int playerCount
private int port
private int seed
private int numHands
private boolean runOnce
private boolean alive
private java.io.FileWriter errorLog
private java.io.FileWriter roomLog
private java.io.BufferedWriter errorLogWriter
private java.io.BufferedWriter roomLogWriter
private static final int ROOM_TIMEOUT
private static int TIMEOUT
private static int PORTBASE
private static boolean SAVE_FLAG
Constructor Detail |
---|
public Room(java.lang.String name, int hands, Gamedef gamedef, int seed) throws java.io.IOException, java.lang.InterruptedException
name
- The name of the match/roomhands
- The number of hands to playgamedef
- The game definition usedseed
- a seed for the cards in the game
java.io.IOException
java.lang.InterruptedException
Method Detail |
---|
private void initLogging()
public void logError(java.lang.Exception ex)
ex
- public void logWarning(java.lang.String warningMessage)
warningMessage
- A message to log to the error logpublic void logInfo(java.lang.String info, boolean toOut)
info
- the message to log to the room logtoOut
- True to print to stdoutprivate void initServerSocket() throws java.net.BindException, java.lang.InterruptedException, java.io.IOException
java.io.BindException
java.InterruptedException
java.io.IOException
java.net.BindException
java.lang.InterruptedException
private void listen() throws java.io.IOException
java.io.IOException
private void startNewDealer()
private void saveDealer()
public void run()
run
in interface java.lang.Runnable
public java.lang.String getStatus()
public java.lang.String getName()
public boolean isAlive()
public int getPort()
public void shutdown()
public java.lang.String toString()
toString
in class java.lang.Object
private static void loadSettings() throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXParseException, org.xml.sax.SAXException, java.io.IOException, java.lang.InterruptedException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXParseException
org.xml.sax.SAXException
java.io.IOException
java.lang.InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |