|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--ServerThread
The ServerThread class is a communications interface between the server and the client.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
ServerThread(Game owner,
java.net.Socket socket,
int threadNum)
ServerThread constructor |
Method Summary | |
int |
getThreadNum()
Returns the thread number of this connection. |
java.lang.String |
getUserName()
Returns the user name of the client connected. |
void |
processCommand(java.lang.String command)
Checks the command received from the client and determines what to do with the information |
void |
run()
Initializes ServerThread, receives input from clients and closes the connection when finished. |
void |
sendCommand(java.lang.String command)
Sends the command parameter to the client. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ServerThread(Game owner, java.net.Socket socket, int threadNum)
ServerThread constructor
Pre-condition: none
Post-condition: ServerThread class created; owner, socket and threadNum are set to values passed
owner
- provides a link back to the gamesocket
- the Socket connection to the clientthreadNum
- an identification number signifying which ServerThread it isMethod Detail |
public void run()
Initializes ServerThread, receives input from clients and closes the connection when finished.
Pre-condition: existing socket connection to a client
Post-condition: data has been received and socket is closed
run
in class java.lang.Thread
public void sendCommand(java.lang.String command)
Sends the command parameter to the client.
Pre-condition: existing socket connection to a client
Post-condition: command parameter is sent to the client
command
- information to be sent to the clientpublic void processCommand(java.lang.String command)
Checks the command received from the client and determines what to do with the information
Pre-condition: command contains the input sent from the client
Post-condition: the input has been processed and the Game is updated
command
- the String recieved from the client to be processedpublic int getThreadNum()
Returns the thread number of this connection.
public java.lang.String getUserName()
Returns the user name of the client connected.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |