Forum Discussion
Satoshi_Toyosa1
Mar 01, 2018Employee
I have just found out that ILX::init cannot be called in a RULE_INIT block: The ILX iRule doc says "Valid During: ANY_EVENT with the exception of RULE_INIT". So, static is not necessary.
If you want to reuse the RPC handle, create the handle in the first event block, and make a proc to accept the handle as an argument. e.g.,
proc send_req {message handle} {
set response [ILX::call $handle AsrFunc1 $message]
return $response
}
when CLIENT_ACCEPTED {
set RPC_HANDLE [ILX::init AsrPlugin "AsrExt"]
log local0. "ACCPT: [call send_req "hello_req" $RPC_HANDLE]"
}
when HTTP_REQUEST {
log local0. "REQ: [call send_req "hello_req" $RPC_HANDLE]"
}
when HTTP_RESPONSE {
log local0. "RESP: [call send_req "hello_resp" $RPC_HANDLE]"
}
An issue is maintainability. When the code becomes longer, finding the RPC_HANDLE variable would become tedious. Also, when you add another event that occurs before the handle initialisation (e.g., FLOW_INIT starts before CLIENT_ACCEPTED), you get a TCL error. So, I would still (personally) go for the init next to call style (assuming ILX::init is cheap).