|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectTTTO.MasterServer.MasterServer
public class MasterServer
Nested Class Summary | |
---|---|
class |
MasterServer.ClientHandler
|
Field Summary | |
---|---|
private java.util.LinkedList<MasterServer.ClientHandler> |
allClients
|
private java.util.LinkedList<Room> |
allGameRooms
|
private int |
hostPort
|
private IMasterServerLog |
logArea
|
private java.util.concurrent.ExecutorService |
pool
|
static java.lang.String |
REGISTER_GAMEROOM
|
static java.lang.String |
RETRIEVE_GAMELIST
|
private java.net.ServerSocket |
serverSocket
|
static java.lang.String |
UNREGISTER_GAMEROOM
|
Constructor Summary | |
---|---|
MasterServer(int aPort,
int aThreads)
Creates a master server keeping track of available games. |
|
MasterServer(int aPort,
int aThreads,
IMasterServerLog aLog)
Creates a master server keeping track of available games. |
Method Summary | |
---|---|
private Room |
findRoomCreatedBySocket(java.net.Socket aClient)
Finds the game room created by a client |
java.lang.String |
getServerStats()
Return some server stats |
static boolean |
isValidCommand(java.lang.String aCommand)
Compares the string to all commands and checks if the string is a command |
void |
log(java.lang.String aMessage)
Logs a message with a timestamp |
private void |
registerGameRoom(Room aRoom)
Registers the game room to the master server. |
void |
runServer()
Starts the server. |
private void |
unregisterGameRoom(Room aRoom)
Unregisters the game room from the master server |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int hostPort
private java.util.concurrent.ExecutorService pool
private java.net.ServerSocket serverSocket
private java.util.LinkedList<MasterServer.ClientHandler> allClients
private java.util.LinkedList<Room> allGameRooms
private IMasterServerLog logArea
public static java.lang.String REGISTER_GAMEROOM
public static java.lang.String RETRIEVE_GAMELIST
public static java.lang.String UNREGISTER_GAMEROOM
Constructor Detail |
---|
public MasterServer(int aPort, int aThreads)
aPort
- The port the server will live onaThreads
- Number of threads in the thread poolaMaxRooms
- How many games that can be registered to the master serverpublic MasterServer(int aPort, int aThreads, IMasterServerLog aLog)
aPort
- The port the server will live onaThreads
- Number of threads in the thread poolaMaxRooms
- How many games that can be registered to the master serveraLog
- Where the log messages will goMethod Detail |
---|
public static boolean isValidCommand(java.lang.String aCommand)
aCommand
- The string to check
public void runServer() throws java.net.UnknownHostException, java.io.IOException
java.net.UnknownHostException
java.io.IOException
public void log(java.lang.String aMessage)
aMessage
- the messageprivate void registerGameRoom(Room aRoom)
Room
- the room to registerprivate void unregisterGameRoom(Room aRoom)
aRoom
- the room to unregisterpublic java.lang.String getServerStats()
private Room findRoomCreatedBySocket(java.net.Socket aClient)
aClient
- The client
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |