|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
dasher.net.NetDasherCommandInterpreterThread
public class NetDasherCommandInterpreterThread
This thread is spawned by NetDasherListener every time a connection is accepted.
The thread is passed references to most of NetDasherListener's internal data, and is responsible for interpreting the incoming request and using these resources to service it appropriately.
Output should also be organised such that the client has received a reply by the time this thread ends.
The input will arrive in XML format; output too should be written as XML.
Input XML
The general format of XML which is expected is:
<command type="message_type">%lt;attribute_1>value%lt;/attribute_1><attribute_2>value</attribute_2>...</command>
Where message_type can be any of:
init -- Starts a new session. Required attributes are width (Client's screen width in pixels) and height (Client's screen height in pixels).
click -- Reports a user mouse click at a given location. Required parameters are x (mouse x co-ordinate) and y (mouse y co-ordinate).
changealphabet -- Changes the alphabet currently in use. Required parameter: name (Name of new alphabet)
changecolours -- Changes the colour scheme currently in use. Required parameter: name (Name of new colour scheme)
Output XML
This class is responsible for producing XML reporting errors in parsing input XML.
For a description of ordinary output returned when the input XML was successfully parsed, see the documentation for NetScreen.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected CAlphIO |
alphIO
AlphIO instance to be supplied to any Dashers created |
protected CColourIO |
colourIO
ColourIO instance to be supplied to any Dashers created |
protected java.net.Socket |
DasherConnection
Socket on which the incoming request arrived, and to which output should eventually be delivered. |
protected java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> |
Dashers
Map indexing the available NetDasherConnectionHandlers by their associated session identifiers. |
protected java.lang.String |
dataLocation
Data location any created Dasher should use to locate training text. |
protected javax.xml.parsers.DocumentBuilderFactory |
db
DocumentBuilderFactory to be used in the course of all XML parsing. |
protected idWrapper |
freeID
idWrapper class to obtain free session IDs. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
NetDasherCommandInterpreterThread(java.net.Socket Connection,
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> dashs,
idWrapper freeIDs,
javax.xml.parsers.DocumentBuilderFactory docbuild,
java.lang.String dataloc,
CAlphIO alphIO,
CColourIO colourIO)
Creates a new command interpreter and passes in working data. |
|
| Method Summary | |
|---|---|
protected int |
getFreeID()
Uses freeID to produce a free ID |
void |
run()
Starts the thread. |
protected void |
writeError(java.lang.String errorString,
java.io.OutputStream m_Output)
Produces an XML document describing a given error and serializes the document to a given OutputStream, typically a network socket. |
| 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, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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 idWrapper freeID
protected java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashers
protected java.net.Socket DasherConnection
protected javax.xml.parsers.DocumentBuilderFactory db
protected java.lang.String dataLocation
protected CAlphIO alphIO
protected CColourIO colourIO
| Constructor Detail |
|---|
public NetDasherCommandInterpreterThread(java.net.Socket Connection,
java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> dashs,
idWrapper freeIDs,
javax.xml.parsers.DocumentBuilderFactory docbuild,
java.lang.String dataloc,
CAlphIO alphIO,
CColourIO colourIO)
The actual interpreting will take place when the thread's start() method is called.
Connection - Socket from which the command should be read
and to which the answer should be written.dashs - Map indexing Dashers by their session IDfreeIDs - Class capable of reliably supplying unique
free session identifiers. Must be thread-safe.docbuild - DocumentBuilderFactory to use for XML reading and writingdataloc - Data location where Dashers can find training textalphIO - AlphIO object describing available alphabetscolourIO - ColourIO object describing available colour schemes| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprotected int getFreeID()
protected void writeError(java.lang.String errorString,
java.io.OutputStream m_Output)
This method is for reporting errors encountered whilst trying to parse the client's request document; errors arising in Dasher itself should be dealt with by other means.
errorString - String to report to the userm_Output - OutputStream to which XML should be serialized
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||