Events in practice

Let's look at a few specific examples that demonstrate the use of events.

Event Socket Library example: running a command

The following PHP example shows how you can write a simple script to take one-line commands and, using the FreeSWITCH Event Socket Library, send those commands to FreeSWITCH, and wait for the response.

// Include FreeSWITCH ESL Library. Note that ESL.php comes // with the FreeSWITCH PHP ESL module. require_once('ESL.php'); if ($argc <= 1) { printf("ERROR: You Need To Pass A Command\nUsage:\n\t%s <command>", $argv[0]); exit(); } // Strip off the executable's name ($argv[0]) array_shift($argv); $command = sprintf('%s', implode(' ', $argv)); printf("Command to run is: %s\n", $command); // Connect to FreeSWITCH ...

Get FreeSWITCH 1.0.6 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.