You can modify the response callback in an asynchronous conversation to verify validity of the responses, or to wait for a specific event. For example, you could check the response headers for each response to determine if a specific value was received.
When the expected value has been received, you can use a web_stop_async step in the Action file to end the asynchronous conversation.
The following code sample provides an example for ending a synchronized conversation. In this example, in the AsyncCallback.c file, the scripts counts 10 iterations of the polling conversation, after which it creates a new parameter, stopAsync.
Example:
int Poll_0_ResponseCB(
...{
//increment iteration counter for every response received.
static int iter = 0;
iter++;
//Once the desired number of responses has been reached,
//create and save the parameter.
if (iter > 10) {
lr_save_int(iter, "stopAsync");
}
return WEB_ASYNC_CB_RC_OK;
}
In the Action file, the web_sync step uses the generated parameter, stopAsync, to end the conversation:
Example:
web_reg_async_attributes("ID=Poll_0","Pattern=Poll",
"URL=http://pumpkin:2080/nioamfpoll;AMFSessionId=6F8D6108-E309-38B2-3D65-963B431D0A38",
"PollIntervalMs=3000",
"RequestCB=Poll_0_RequestCB",
"ResponseCB=Poll_0_ResponseCB",
LAST);
web_custom_request("nioamfpoll;AMFSessionId=6F8D6108-E309-38B2-3D65-963B431D0A38_2",
"URL=http://pumpkin:2080/nioamfpoll;AMFSessionId=6F8D6108-E309-38B2-3D65-963B431D0A38",
"Method=POST",
"Resource=0",
"RecContentType=application/x-amf",
"Referer=http://pumpkin:8081/lcds-samples/traderdesktop/traderdesktop.swf/[[DYNAMIC]]/3",
"Snapshot=t11.inf",
"Mode=HTML",
"EncType=application/x-amf",
"BodyBinary=\\x00\\x03\\x00\\x00\\x00\\x01\\x00\\x04null\\x00\\x02/6\\x00\\x00\\x00Z\n\\x00\\x00\\x00\\x01\\x11\n\\x07\\x07DSC\\x8D\\x02\n\\x0B\\x01\\x01\\x06\\x01\n\\x05\tDSId\\x06I6F8D611E-DC1C-9D0C-2BBA-36CC2AB8633B\\x01\\x0C!\\xC0\\xBE\\xA6Z74\\xBE\\xC3\\xCF\\xC7\\xFA\\xE6\\xC3\t\\xE2\\x92\\x01\\x06\\x01\\x01\\x04\\x02",
LAST);
lr_think_time(30);
//suspend the script until the desired number
//of iterations have been performed.
web_sync("ParamCreated=stopAsync", "RetryIntervalMs=1000", "RetryTimeoutMs=300000", LAST);
web_stop_async("ID=Poll_0",LAST);
For more details about ending an asynchronous conversation, see Defining the End of an Asynchronous Conversation.
Back to top