Example: nca_java_set_reply_property

Example 1

In this example, the nca_java_set_reply_property function sets several Java properties.

char* JavaProp[][3] = {{"GetHost", "HostName", "servername"},
          {"GetHost", "HostIP", "127.0.0.1"},
          {0,0,0}};

nca_connect_server(...);
nca_java_set_reply_property(JavaProp);
 Example 2
In this example, nca_java_set_reply_property is used for preventing errors resulting from missing information on java objects.
The message "Warning: did not reply to property - 402" for a java object (handlerClassId=0x10F) means the server requested information and the answer is not available. The answers can be found in the recording log. 
For example, this recording log shows two such events.
In the first, the property requested is "ctiEnabled" and the value is "TRUE". 
Server Message Properties: action=4 handlerClassId=0x10F handlerId=20
    property=402 type=0x4000 value="ctiEnabled"
Server Terminate Message: #5
Client Message Properties: action=4 handlerClassId=0x10F handlerId=20
    property=402 type=0x4000 value="TRUE"
Client Terminate Message: #6
In the second, the property requested is "message" and the value is "Unknown property: BACKGROUND"
Server Message Properties: action=4 handlerClassId=0x10F handlerId=20
    property=402 type=0x4000 value="message"
Server Terminate Message: #7
Client Message Properties: action=4 handlerClassId=0x10F handlerId=20
    property=402 type=0x4000 value="Unknown property: BACKGROUND"
Client Terminate Message: #8
The object name in the example is known from the recording log. A call to nca_java_action("CONTROL_CTI_CLIENT_0", "errorEvent","") is recorded before the logon.
This example from the vuser_init action shows how to solve the problem. First, create an array where each element contains the object name, the requested property from the recording log, and the answer from the recording log. Then, pass the array as an argument to nca_java_set_reply_property before connecting to the server:
/* The first two elements in array JavaProp provide the missing replies.
   The third element, {0,0,0}, terminates the array. */
char* JavaProp[][3]= {
    {"CONTROL_CTI_CLIENT_0", "ctiEnabled", "TRUE"},
    {"CONTROL_CTI_CLIENT_0", 
        "message", "Unknown property: BACKGROUND"},
    {0,0,0}
};
vuser_init() {
    nca_set_connect_opt(SCALE_INFO, 11, 18);
    nca_set_connect_opt(REQUIRED_LIST, 0);
    /* Set the reply before connecting to the server */
    nca_java_set_reply_property(JavaProp);
    
    nca_connect_server("kellynch.hall.com", 
        "80", 
        "module=DTCFM000 record=names");