This example shows the following features:
Use of standalone messenger
Requesting a list of agents
Sending a message
Receiving a message
The standaloneClient program shows how regular Java programs (neither agents nor habitats) can communicate with agents in a habitat. It uses JXTA (www.jxta.org), a peer-to-peer communication protocol. JXTA communication is a new feature implemented since the ADK 2.0 release.
Go to the scenarios directory and start a habitat by typing habitat.bat chat1.xml Alternatively, you could use chat3.xml.
As it starts, the habitat shows its habitat id. The line that is displayed should look similar to
Habitat ID: 60000003-00000000c0a80083
Make a note of the habitat id or put it in the clipboard. (A future release of the JXTA implementation will support automatic discovery of habitats, removing the need to enter the address).
Start a command prompt in a separate window or on a separate machine. Go to the directory <ADK_ROOT>\scenarios\standalone. Run the script standalone.bat -h habitat-id, where habitat-id is the habitat id obtained above. For example,
standalone -h 60000003-00000000c0a80083
The standalone client will report the agents available in the habitat. Pick an agent by typing its number. Now you can send messages to that agent. Type quit to stop. The messages sent to the agent will show up as messages in the habitat window.
Note: If you send messages to a system agent, it will reply with a not understood message because it does not implement the chat language.
Known issues of the JXTA implementation include
Setting up communication may take some time.
Some agents are system agents, these will not chat.
A remedy for the first issue is to delete the .jxta directories prior to starting. These directories are created in the scenarios directory and the scenarios/standalone directory. For more information refer to the Developer's Guide chapter on Configuration which further discusses multi-machine JXTA setup.