PV-WAVE Advantage > JWAVE User Guide > JWAVE Server Development > Returning Multiple Results to the Client
Returning Multiple Results to the Client
 
warning
JWAVE uses an insecure protocol without authentication. This makes JWAVE insecure to use in an Internet facing configuration and would allow an attacker to execute arbitrary code on the server. If you choose to implement JWAVE in this way, you are responsible for the security of those applications that leverage JWAVE.
You can package multiple results (arrays and scalars) and return them to the client where they can be unpacked and used.
To package multiple results on the server, create and return an associative array of data name/value pairs. For example, the following JWAVE wrapper function returns multiple results to the client:
FUNCTION PASSFFT, client_data
; Get the data from the client. 
arr = GETPARAM(client_data, 'ARRAY', /Value)
;Process the data, creating two separate variable results 
freq = FLOAT(ABS(FFT(arr, -1)))
distrib = HISTOGRAM(freq)
; Create associative array to send results back to the client. 
RETURN, ASARR('FDATA', freq, 'HIST', distrib)
END
The resulting arrays, freq and distrib are packaged and returned to the client in the associative array. The associative array keys become the names of the returned data referenced by the client with the getReturnData method. The names of the data returned by this example are FDATA and HIST.
The following example shows a Java code fragment used to retrieve the parameters sent from the server and to properly cast the values.
Client calls to unpack associative array sent from the server.
//Get the FFT data 
float[] d = (float[]) command.getReturnData(”FDATA”);
//Get the histogram data 
int[] h = (int[]) command.getReturnData(HIST”);