Part 12: Programming with the Event Socket and Scripting
The integration chapters showed how to configure the Event Socket and the scripting modules. This part shows how to program with them. It covers FreeSWITCH's event model and a catalog of the events you will consume, the two Event Socket modes — inbound (your code connects to FreeSWITCH) and outbound (FreeSWITCH connects to your code) — and the embedded scripting APIs for driving a call from Lua or JavaScript. It is a developer's companion to the reference, focused on the programmable surface rather than the configuration.
The Event Model
How FreeSWITCH represents everything significant as a typed event with named headers and an optional body, the SWITCH_EVENT_* family, the headers every event carries, and the channel lifecycle as a stream of events.
Events Catalog
Reference catalog of FreeSWITCH events: when each fires, its notable headers, and whether it is a first-class event or a CUSTOM subclass.
ESL: Inbound
Connect to FreeSWITCH's event_socket listener from your own program: the wire protocol, the ESL client library, and a worked event-consuming loop.
ESL: Outbound
How FreeSWITCH connects out to your server with the socket dialplan application, the connect/linger/myevents handshake, the sync and async execution models, and a worked outbound handler built on the ESL library.
Scripting APIs
The shared scripting surface for mod_lua and mod_v8: the Session object, freeswitch.API, freeswitch.Event, consoleLog, and stream output, with parallel Lua and JavaScript examples.