|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
net.sf.freecol.common.networking.ReceivingThread
final class ReceivingThread
The thread that checks for incoming messages.
| Nested Class Summary | |
|---|---|
(package private) class |
ReceivingThread.FreeColNetworkInputStream
Input stream for buffering the data from the network. |
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
private Connection |
connection
|
private ReceivingThread.FreeColNetworkInputStream |
in
|
private boolean |
locked
|
private static java.util.logging.Logger |
logger
|
private static int |
MAXIMUM_RETRIES
Maximum number og retries before closing the connection. |
private int |
nextNetworkReplyId
|
private boolean |
shouldRun
|
private java.util.Map<java.lang.Integer,NetworkReplyObject> |
threadsWaitingForNetworkReply
|
private javax.xml.stream.XMLStreamReader |
xmlIn
|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
ReceivingThread(Connection connection,
java.io.InputStream in,
java.lang.String threadName)
The constructor to use. |
|
| Method Summary | |
|---|---|
(package private) void |
askToStop()
Tells this thread that it doesn't need to do any more work. |
private void |
disconnect()
|
int |
getNextNetworkReplyId()
Gets the next networkReplyId that will be used when
identifing a network message. |
private void |
listen()
Listens to the inputstream and calls the messagehandler for each message received. |
void |
run()
Receives messages from the network in a loop. |
private boolean |
shouldRun()
Checks if this thread has been halted. |
void |
unlock()
|
NetworkReplyObject |
waitForNetworkReply(int networkReplyId)
Creates and registers a new NetworkReplyObject with the
specified ID. |
NetworkReplyObject |
waitForStreamedNetworkReply(int networkReplyId)
Creates and registers a new NetworkReplyObject with the
specified ID. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, clone, 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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger logger
private static final int MAXIMUM_RETRIES
private final ReceivingThread.FreeColNetworkInputStream in
private javax.xml.stream.XMLStreamReader xmlIn
private boolean shouldRun
private int nextNetworkReplyId
private final java.util.Map<java.lang.Integer,NetworkReplyObject> threadsWaitingForNetworkReply
private final Connection connection
private boolean locked
| Constructor Detail |
|---|
ReceivingThread(Connection connection,
java.io.InputStream in,
java.lang.String threadName)
connection - The Connection this
ReceivingThread belongs to.in - The stream to read from.| Method Detail |
|---|
public int getNextNetworkReplyId()
networkReplyId that will be used when
identifing a network message.
networkReplyId.public NetworkReplyObject waitForNetworkReply(int networkReplyId)
NetworkReplyObject with the
specified ID.
networkReplyId - The id of the message the calling thread should
wait for.
NetworkReplyObject containing the network
message.public NetworkReplyObject waitForStreamedNetworkReply(int networkReplyId)
NetworkReplyObject with the
specified ID.
networkReplyId - The id of the message the calling thread should
wait for.
NetworkReplyObject containing the network
message.public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic void unlock()
private void listen()
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.stream.XMLStreamException
java.io.IOException - If thrown by the ReceivingThread.FreeColNetworkInputStream.
org.xml.sax.SAXException - if a problem occured during parsing.
javax.xml.stream.XMLStreamException - if a problem occured during parsing.private boolean shouldRun()
void askToStop()
private void disconnect()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||