|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdasher.net.NetDasherListener
public class NetDasherListener
Main class powering NetDasher. This class listens for connections and, whenever one is received, spawns a NetDasherCommandInterpreterThread to determine what the client wants, and action their request.
Alphabet and Colour XML files are also read on startup to produce central AlphIO and ColourIO objects, which are passed in to every created Dasher; this way we avoid the tedious work of repeatedly parsing the same data for each instance of Dasher we create.
Essentially the goal is to create an instance of Dasher, attached to a NetScreen, for each client, and to pass the user's clicks and other requests to the appropriate instance of Dasher as connections come in.
Since connections are conducted by HTTP for most clients and forwarded by a simple PHP script, there are no persistent connections -- there is only one connection per request and vice versa.
| Field Summary | |
|---|---|
private static java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> |
Dashers
HashMap of session identifiers to instances of Dasher, passed to each CommandInterpreterThread. |
private static java.lang.String |
dataLocation
Location to look for alphabet and colour XML files, as well as training texts. |
private static javax.xml.parsers.DocumentBuilderFactory |
dbf
DOM parser factory for XML. |
private static java.util.Timer |
GCScheduler
Timer which runs a NetDashGC thread every 60 seconds |
private static idWrapper |
nextID
Next free session identifier |
| Constructor Summary | |
|---|---|
NetDasherListener()
|
|
| Method Summary | |
|---|---|
static void |
main(java.lang.String[] args)
Creates our listening socket, schedules the garbage collector thread to run every 60 seconds, creates instances of CAlphIO and CColourIO to read in the appropriate XML data, and finally enters a tight loop of accepting connections and spawning NetDasherCommandInterpreterThreads to deal with them. |
static void |
ScanAlphabetFiles(java.util.ArrayList<java.lang.String> vFileList)
|
static void |
ScanColourFiles(java.util.ArrayList<java.lang.String> vFileList)
|
static void |
ScanFilesByRegex(java.util.ArrayList<java.lang.String> vFileList,
java.lang.String regex)
Delegate method used by both ScanAlphabetFiles and ScanColourFiles. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.util.concurrent.ConcurrentHashMap<java.lang.Integer,NetDashConnectionHandler> Dashers
private static java.lang.String dataLocation
private static javax.xml.parsers.DocumentBuilderFactory dbf
private static java.util.Timer GCScheduler
private static idWrapper nextID
| Constructor Detail |
|---|
public NetDasherListener()
| Method Detail |
|---|
public static void ScanAlphabetFiles(java.util.ArrayList<java.lang.String> vFileList)
public static void ScanColourFiles(java.util.ArrayList<java.lang.String> vFileList)
public static void ScanFilesByRegex(java.util.ArrayList<java.lang.String> vFileList,
java.lang.String regex)
Fills its first parameter with all files in our systemLocation which match the given regex.
vFileList - List to fill with matching filesregex - Regular expression determining what to addpublic static void main(java.lang.String[] args)
The first argument is taken as the data location where XML files and training texts may be found.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||