I am using Mod lua for call processing on the FreeSwitch. I would like to wait for some events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to get the answer time and hangup time. Basically, something like
Wait for event CHANNEL_ANSWER or CHANNEL_HANGUP
If (event_name = “CHANNEL_ANSWER”) then answer_timestamp = getHeader(“Caller-Channel-Answered-Time”)
If (event_name = “CHANNEL_HANGUP”) then hangup_timestamp = getHeader(“Event-Date-Timestamp”)
The session:getState() described in module lua gets the call state but not the channel state. For instance, ‘CS_EXECUTE’ is the channel state when it is executing a dialplan not when the call is answered.
Is there a way to wait for channel events such as CHANNEL_ANSWER and CHANNEL_HANGUP in order to retrieve answer and hangup timestamps for a call?
Any input is very much appreciated.
Thanks.
Sam