Sorry that we didn't reply to this sooner - have both been travelling. Thanks for giving us a kick :-)
First of all, you should never use the Messenger object directly, this is for internal use in the JavaAIRPlug object only.
You should always use the JavaAIRPlug object as this will ensure that everything is initialised properly before you start using it.
You do that like this:
private JavaAIRPlug plug;
plug = new JavaAIRPlug(name, host, port);
if (!plug.init()) {
System.out.println("Could not connect to the Server on " + host +
" on port " + port + "...");
System.exit(0);
}
Now the plug is registered with Psyclone, but you have not yet asked for any messages (triggers or retrieves).
If you merely want to retrieve data yourself from Whiteboards and never be triggered by postings from other modules, you can use the following API:
ObjectCollection coll = plug.retrieveMessages(String retrieveSpecXML);
with your xml ("<retrieves><retrieve from...") as the argument. You can call this as often as you like, and you will never be pushed any messages. I would strongly recommend that you always have this main loop in your code:
Message message;
while (true) {
if ( (message = plug.waitForNewMessage(100)) != null) {
// ignore it
}
}
or at least regularly call the waitForNewMessage(ms) function as it makes sure that the channel to Psyclone is managed properly.
You can, however, also do as Kris suggests, and use a trigger to be pushed the information when something happens. Say, for example, that you wish to do your retrieve every time message x.y.z is posted on Whiteboard WB1. You can then register your plug module with the following spec:
<module name="mymodule" type="external">
<trigger from="WB1" type="x.y.z"/>
<retrieve from="WBX" type="Input.Sens.MultiM.Vision.Human">
<latest>3</latest>
<lastmsec>8000</lastmsec>
</retrieve>
</module>
Now, in your loop do this:
Message message;
while (true) {
if ( (message = plug.waitForNewMessage(100)) != null) {
// got the trigger for x.y.z
// Get the current number of retrieved messages
n = plug.getRetrievedMessageCount();
// get all retrieved messages
ObjectCollection coll = getAllRetrievedMessages();
// or get only the second retrieved message
Message rmsg = getRetrievedMessage(2);
}
}
You can choose to either enter your module registration XML in the PsySpec XML file or as a parameter to the init() function just after creating the plug:
if (!plug.init(xml)) { // xml = "<module name...>"
}
By the way, which version of Psyclone are you using? If you are using anything older than version 1.0.6, please download the latest version from
http://www.mindmakers.org/projects/PsycloneThis contains the manual and tutorials, which you can also see at
http://www.cmlabs.com/psyclone/manualThis contains lots of examples of how to do many different things. See especially
Part 4: USE CASES
I hope that this helps. We have made things much better and simpler in the past year, so I hope that you don't get too confused if you are used to a much older version of Psyclone.
Please keep posting problems - we need to hear these as much as you need the help.