|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--thegame.server.GameServer
The central server that the GameClients connect to.
Field Summary | |
protected java.lang.String |
administratorPassword
The administrator password. |
protected java.util.ArrayList |
connections
Is used to hold all the ongoing GameServerConnections. |
static java.lang.String[] |
FORBIDDEN_PLAYER_NAME_SUFFIXES
|
static int |
MAXIMUM_PLAYER_NAME_LENGTH
|
static int |
MINIMUM_PLAYER_NAME_LENGTH
|
static java.lang.String |
PASSWORD_CORRECT_MESSAGE
The message displayed if the administrator password was correct. |
static java.lang.String |
PASSWORD_NOT_CORRECT_MESSAGE
The message displayed if the administrator password was not correct. |
static java.lang.String |
PLAYER_NAME_CONTAINS_FORBIDDEN_TEXT_MESSAGE
The error message sent if the player entered a name that contains forbidden text. |
static java.lang.String |
PLAYER_NAME_IN_USE_MESSAGE
The error message sent if the player entered a name that is already in use. |
static java.lang.String |
PLAYER_NAME_OF_FORBIDDEN_LENGTH_MESSAGE
The error message sent if the player entered a name of forbidden length. |
protected java.net.ServerSocket |
serverSocket
The socket that accepts incoming connections. |
static java.lang.String |
STARTUP_MESSAGE
The message displayed when GameServer starts. |
static java.lang.String |
STARTUP_PASSWORD_PROMPT_MESSAGE
The password prompt shown at startup. |
protected java.lang.String |
waitingPlayersNamesList
Holds the names of the waiting players in a ready-to-send form. |
Constructor Summary | |
GameServer(int port)
Constructs a GameServer listening on the specified port. |
Method Summary | |
void |
handleCreateGameMessage(GameServerConnection sender,
boolean isPlayerDrawingCircles)
Handles a message to create a new game. |
void |
handleJoinGameMessage(GameServerConnection sender,
java.lang.String remoteName)
Handles a message to join a game. |
void |
handlePlayerMessage(GameServerConnection sender,
java.lang.String message)
Handles the messages sent from player to system (i.e. from GameClientConnection to GameServer). |
void |
handlePlayerNameMessage(GameServerConnection sender,
java.lang.String name)
Handles a message that establishes the name of a player. |
void |
handlePlayerQuitMessage(GameServerConnection sender)
Handles a message that reports the departure of a player. |
void |
handlePlayerReturnedToStartScreenMessage(GameServerConnection sender)
Handles a message that reports that a player returned to start screen |
void |
handlePlayerWaitedForNewPlayerMessage(GameServerConnection sender)
|
void |
handleReadyForPlayerListMessage(GameServerConnection sender)
Handles a message that reports that a player is ready to receive a playerlist. |
void |
handleShutdownMessage(GameServerConnection sender,
java.lang.String password)
Shuts down GameServer if the password is correct. |
static void |
main(java.lang.String[] args)
Starts up a GameServer on the local machine. |
void |
sendWaitingPlayersNames()
Sends the names of the waiting players to all players who are able to see the list of the waiting players. |
void |
updateWaitingPlayersNames()
Updates the names of the waiting players. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String administratorPassword
protected java.util.ArrayList connections
public static final java.lang.String[] FORBIDDEN_PLAYER_NAME_SUFFIXES
public static final int MAXIMUM_PLAYER_NAME_LENGTH
public static final int MINIMUM_PLAYER_NAME_LENGTH
public static final java.lang.String PASSWORD_CORRECT_MESSAGE
public static final java.lang.String PASSWORD_NOT_CORRECT_MESSAGE
public static final java.lang.String PLAYER_NAME_CONTAINS_FORBIDDEN_TEXT_MESSAGE
public static final java.lang.String PLAYER_NAME_IN_USE_MESSAGE
public static final java.lang.String PLAYER_NAME_OF_FORBIDDEN_LENGTH_MESSAGE
protected java.net.ServerSocket serverSocket
public static final java.lang.String STARTUP_MESSAGE
public static final java.lang.String STARTUP_PASSWORD_PROMPT_MESSAGE
protected java.lang.String waitingPlayersNamesList
Constructor Detail |
public GameServer(int port) throws java.io.IOException
port
- the port to be listened onjava.io.IOException
- if an I/O error occursMethod Detail |
public void handleCreateGameMessage(GameServerConnection sender, boolean isPlayerDrawingCircles)
sender
- the GameServerConnection that sent the messagepublic void handleJoinGameMessage(GameServerConnection sender, java.lang.String remoteName)
sender
- the GameServerConnection that sent the messagepublic void handlePlayerMessage(GameServerConnection sender, java.lang.String message)
sender
- the GameServerConnection that sent the messagemessage
- the message sent by the playerpublic void handlePlayerNameMessage(GameServerConnection sender, java.lang.String name)
sender
- the GameServerConnection that sent the messagename
- the entered namepublic void handlePlayerQuitMessage(GameServerConnection sender)
sender
- the GameServerConnection that sent the messagepublic void handlePlayerReturnedToStartScreenMessage(GameServerConnection sender)
sender
- the GameServerConnection that sent the messagepublic void handlePlayerWaitedForNewPlayerMessage(GameServerConnection sender)
public void handleReadyForPlayerListMessage(GameServerConnection sender)
sender
- the GameServerConnection that sent the messagepublic void handleShutdownMessage(GameServerConnection sender, java.lang.String password)
sender
- the GameServerConnection that sent the messagepassword
- the administrator passwordpublic static void main(java.lang.String[] args)
public void sendWaitingPlayersNames()
public void updateWaitingPlayersNames()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |