|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread org.jogre.common.AbstractConnectionThread
Abstract connection thread which is spawned with each client. This extends a thread and stores a Socket to the client, and a BufferedReader and PrintStream which can read/write Strings to the user/server. Also the username of the client is stored in the username String.
Field Summary | |
protected boolean |
connected
All clients start initially with "connected" equal to false (although they can still recieve/transfer logon information). |
protected BufferedReader |
in
Buffered input. |
protected boolean |
loop
When the boolean loop becomes false the Thread finishes. |
protected PrintStream |
out
PrintStream for the output. |
protected Socket |
socket
Socket between the server and the user. |
protected String |
username
Username of the client. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
AbstractConnectionThread(Socket socket)
Constructor for a connection which takes a Socket and sends up the input and output stream. |
Method Summary | |
abstract void |
cleanup()
This method is called to properly clean up after a client. |
void |
connect()
Set boolean to specify that this client has connected sucessfully. |
Socket |
getSocket()
Returns the Socket of this connection. |
String |
getUsername()
Returns the username. |
abstract void |
parse(XMLElement message)
This abstract method must be overwritten by a child which extends this class. |
void |
run()
Run method - runs until an exception has occured or the loop variable becomes false. |
protected void |
send(ITransmittable transObject)
Send a ITransmittable object to the output stream (could be server or client). |
void |
setUsername(String username)
Set the username. |
void |
stopLoop()
Stop the loop. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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 |
Field Detail |
protected Socket socket
protected BufferedReader in
protected PrintStream out
protected String username
protected boolean loop
protected boolean connected
Constructor Detail |
public AbstractConnectionThread(Socket socket)
socket
- Socket connection to client / server.Method Detail |
public abstract void parse(XMLElement message) throws TransmissionException
message
- Communication as an XML object.
TransmissionException
- This is thrown if there is a problem parsing the String.public abstract void cleanup()
public void run()
Runnable.run()
public void stopLoop()
public void connect()
protected void send(ITransmittable transObject)
transObject
- public Socket getSocket()
public String getUsername()
public void setUsername(String username)
username
- Username of client / server who created this thread.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |