[new AC] Data exchange fail between Java client and Java Agent ! [message #116178] |
Tue, 23 October 2007 06:31  |
Eclipse User |
|
|
|
Originally posted by: mlafon.arcadsoftware.removethis.com
I just try to use the TPTPJavaAgent with an modified version of the
SampleClientAC (I just change the name of the agent used to
JavatimeCollector), with TPTP 4.4.0.3.
After some work to config the agent... If the agent is not launched with
the good parameter this causes JVM crash, this can bereally confusing in
a deployment stage. Any way, I get the agent working and this is what I
get on the Client conseole :
Testing Agent Controler Server...
Connecting to Host localhost
Connecting to AC..
Connected to localhost at port number 10006
Connected to org.eclipse.tptp.JavaTimeCollector
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
The Data received from TimeCollector - JTC HELLO
Data Processor Waiting for Data Called
"JTC HELLO" is the data send by the agent, except that the agent send
"JTC HELLO FROM JTC ".
In fact, there is an conversion problem in the sendData :
super.sendData(destID,"JTC HELLO FROM JTC ".toCharArray());
the data are sent to the Native in the form of array of char (char in
java are 2 byte data, I gess ?).
The client get an incomingData with an array of byte and the lenght is
the lenght of the array of char, the HALF of the real byte array size.
To get all the data I need to double the string, something like this :
public int sendData(int targetInstanceId, String buffer)
throws AgentControllerUnavailableException {
// double string length
buffer = buffer + buffer;
return super.sendData(targetInstanceId, buffer.toCharArray());
}
And the client need to remove the last character of the received string :
public void incomingData(byte[] buffer, int length, InetAddress peer) {
String data = new String(buffer,0,length-1); // Remove last char !!!
...
}
This is working but this is ugly !
Finally, I get the answer of my previous question, the new Java API has
not been tested.
Marc.
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05758 seconds