API command
API commands are the way to interact in real time with FreeSWITCH. You can use API commands to originate a call, to answer, to gather statistics, to write accounting data, to shutdown the entire system, and more.
API commands are commands you can type while you're connected to FreeSWITCH's console, or via fs_cli
. You can send API commands by firing events, both from a module and via an ESL TCP connection.
Modules can add new such functionalities; actually, pretty much all API commands come from modules:
We registered our API command during the LOAD
function, as per the dialplan application.
example_api()
is the function that implements the API command. We use it as a demonstration of how to send an event from a module.
First, you create the event pointer, then you give it an earthly existence with switch_event_create()
, passing the event-specific kind as an argument.
At this point you have an empty event, a skeleton event with only the standard minimal headers (fields). You can flesh...