|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
GameServer
public abstract class GameServer
This static side of this class is the Server side Application for a client/server Othello Game. Objects of this class are also used to communicate to individual threads via multithreading.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
GameServer(java.net.Socket initConnection,
int initPlayerNumber)
This constructor initializes the server by setting up all Object I/O to be used to communicate back and forth with this client. |
|
| Method Summary | |
|---|---|
void |
assignColors()
Assigns colors to the two opponents. |
boolean |
createProfile()
Creates a user profile so the user can now have access to the server and play 2player games |
boolean |
findOpponent()
Finds an opponent for this player and sets this player as the opponent of another player |
int |
getBoardReference()
|
GameServer |
getOpponent()
|
int |
getPlayerNumber()
|
boolean |
login()
Allows users who connect to log in to the server. |
abstract void |
modifyScore()
Compares the winner of the game with the player's playerNumber, then modifies the stats of the player. |
void |
resetStats()
Resets the stats of the player in the current game(Wins, Losses, Ties) |
abstract void |
restartGame()
This method restarts a game either after a draw or after a player has won. |
boolean |
saveProfile()
Method used to save the current profile in a file on the server. |
void |
selectGame()
User selects a game. |
void |
sendNetworkObject(GameNetworkObject tttno)
This method is used to send a message to the client handled by this thread. |
void |
setBoardReference(int newRef)
|
void |
setColor(int color)
Manually assigns a color to the player |
void |
setOpponent(GameServer newOpponent)
Sets an opponent for this player |
void |
setPlayerNumber(int pn)
Changes the players number |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public GameServer(java.net.Socket initConnection,
int initPlayerNumber)
initConnection - - socket that is connected to a clientinitPlayerNumber - - represents the player number for the
client that will be communicated with by this thread.| Method Detail |
|---|
public abstract void restartGame()
public void setPlayerNumber(int pn)
pn - - integer containing the player's new numberpublic int getPlayerNumber()
public void assignColors()
public void setColor(int color)
color - public abstract void modifyScore()
winner - - the player that won the gamepublic GameServer getOpponent()
public void setOpponent(GameServer newOpponent)
public boolean findOpponent()
public void resetStats()
public void sendNetworkObject(GameNetworkObject tttno)
tttno - - the network packet to be sent to the client
handled by this thread.public boolean saveProfile()
public boolean login()
public void selectGame()
public boolean createProfile()
public int getBoardReference()
public void setBoardReference(int newRef)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||