The Provider object serves as the dispatcher for PrivateDataRequests using the sendPrivateData() method. This method takes a PrivateDataObject (a CSASetEvtMonDataObj or a CSARemProcCallDataObj), wraps it into a PrivateDataRequest and routes it to the CallPath Enterprise Server, where it will be redirected to the appropriate daemon. This method blocks until the response is received. After the response is received, the application can retrieve the byte array (from getByteArray()) containing the response information. Parsing and translation of this byte array are left to the application.
The following is an outline of the code for setting monitoring on an object.
// Create the data object to be sent giving the numeric (a short)
// value of the event to monitor for, the mode (1 for
// TADS_START_MONITORING, 0 for TADS_STOP_MONITORING) and a byte
// array containing additional information if the monitor
// requires it
CSASetEvtMonDataObj monitorObject =
new CSASetEvtMonDataObj((short)9428, (short)1, null);
// Cast the provider to Private Data to access the methods of the
// JTAPI interface and pass the data object to the send method to
// be delivered to the CPE Server
((PrivateData) myProvider).sendPrivateData( (Object) monitorObject );
// At this point if there is a ProviderObserver on the Provider
// object, any events of type 9428 will be received
The following is an outline of the code for making a Remote Procedure Call to a CallPath Enterprise Daemon.
// Create a byte array to contain the data for the function call
// (parameters). The user must know what the format must be to
// satisfy the expectations of the particular daemon
byte[] messageContents;
.
.
.
// Build the contents of the message as expected by the
// daemon for the particular function.
.
.
.
// Create the Remote Procedure Call data object and identify
// your daemon and function
CSARemProcCallDataObj myMessage =
new CSARemProcCallDataObj("MYDAEMON", "MYFUNCTIONNAME",
messageContents);
// Send the request through the Provider cast as a
// JTAPI PrivateData object
((PrivateData) myProvider).sendPrivateData( (Object) myMessage );
// Get the Response data (in byte form) from the message
// once the send is complete. Processing of this array is
// up to the application.
byte[] responseDataBuffer = myMessage.getByteArray();