The usage is quite straightforward. Let's assume that you want to use a script function that internally performs some I/O operations (such as a DB query). First of all, you need to check whether this script function supports asynchronous mode. (See the respective module documentation for this.) Then, you can just throw it in the following function call:
async(script_function(...), resume_route);
Note that resume_route
has to be a simple, named script, subroute. When a function is called in the asynchronous manner, the script is immediately halted, so any code that you write after the async()
call will be ignored. OpenSIPS will launch the asynchronous operation; after this, it will continue to process any other pending tasks (queued SIP messages, timer jobs, or possibly other asynchronous operations). As soon as the asynchronous operation is complete and all the data is available, OpenSIPS will run the given resume route and continue processing with...