Version 14 (modified by jherwitz, 13 years ago) (diff) |
---|
Java Quagents Client
The Java Quagents Client is made of two parts - the core API and the front-end Scenarios. The API is meant for internal development, and will usually not be necessary to modify for most intents and purposes. The front-end is meant for general user development - research, education, et cetera. This wiki is meant to detail the abstract structure of the client. For information on usage, see the Java Client Tutorial.
Compiling The Client
To compile the client, simply navigate to the client/API/ directory and type "ant". To remove the associated build directory and executable jar, type "ant clean".
Launching The Client
The server and client must be launched independently. The server must be running when the client jar is executed.
To start the server:
- Navigate to the top-level quagents directory.
- Launch the server using the run script by executing "./run.sh <builddir>", where <builddir> corresponds to the directory which you specified during initial installation.
NOTE: if you receive an error when attempting to run the script, use the command "chmod u+x run.sh" to fix.
To start the client:
- Navigate to <topdir>/client/API/, where <topdir> corresponds to the top-level quagents directory.
- Execute the command "java -jar Quagents3.jar <SCENARIONAME> <MAP>".
- For a list of usable maps and scenarios, execute "java -jar Quagents3.jar" (note: this is not synchronized with new maps and scenarios automatically, these must be inserted at ScenarioStarter?.java).
Internal Structure
Entities
All objects in quake which may impact the game world are treated as Entities, and represented with the Entity interface. This includes both the GOD (Director) and Quagents. All Commands and ReaderThreads? (see below) use entities to perform internal operations, so socket operations are independent of entity type.
Client (Entity)
The Client entity is an implementation of a QuagentEntity?, which is a derived form the aforementioned Entity. It represents a Quagent in the Quake world. The Client is notable because it provides a multitude of convenience methods for executing Commands. We realize that the usage of the original Command execution may unintuitive for some users, so this provides a more functional paradigm.
Commands
The Java client is built on Command objects. These objects each represent one or more commands. ProtocolZero commands have a one-to-one correspondance with the commands detailed in ProtocolOZero?. They do not instrument or interpret function, and may be thought of as simply wrapping the protocol commands. ProtocolOne commands, on the other hand, may have an arbitrary level of complexity, or may even not deal with quake at all! These commands may call one or more ProtocolZero commands, and adjust or interpret data to developer desire. An example may be found in CartesianSensor2D.java. Each command must first be instantiated, which sets all relevant parameters and generates necessary structures for use in data retrieval. At this point, the Command is independent of a command "executor". Once the command is constructed, it must then be attached to an executor. This may most easily be accomplished by using the Entity execute() or start() functions, the difference being that execute() blocks until the command is completed while start() does not. Once the command has completed execution, the user may access data by calling Command-specific functions. It is important to note that these functions do not block for return, so it is recommended that users use caution when executing non-periodic commands.
Periodic Commands
Each Command also has an associated periodic functionality. If desired, the user may add an additional argument to the end of any constructor (or Client entity function), and the Command will execute automatically (in a separate thread) at a period of that many milliseconds. This is very useful for sensors or other queries that the user might want to be updated frequently or automatically.
ReaderThread?
Another important structure is the non-blocking ReaderThread?. Each entity has a ReaderThread? associated with it, which handles read operations from the socket. Once a message is read, it is parsed and interpreted, at which point the ReaderThread? locates the Command object associated with the message (by using the command ID and a list of currently running operations) and performs the relevant operation.
Listeners
Multiple types of swing-like action listeners have been implemented. The user may choose to use these to achieve a reactive paradigm code style, or mix them with aforementioned styles to create a custom code style.
Event
Command Termination
External (User-Level) Structure
List of Files
For More Information
For more detailed information on class and method uses, see the javadoc, located at <topdir>/client/API/doc/
Attachments (1)
- Java_Duke.png (13.4 KB) - added by jherwitz 13 years ago.
Download all attachments as: .zip