Session waitForAnswer

From FreeSWITCH Wiki

Jump to: navigation, search

waitForAnswer blocks (waits) until the channel is in a fully answered state. It can be useful for example after an originate to wait for a full answer instead of just early media. It takes an optional parameter which is the amount of time to delay before returning. It returns true if the channel is answered and false if not, i.e. when timed out.

Synopsis

waitForAnswer(timeout)
  • timeout - the duration in milliseconds to wait
  • returns true when the call is answered and false when timed out

Example

new_session = new Session();
new_session.setCallerData("caller_id_name", "fred");
new_session.setCallerData("caller_id_number", "2121231234");
new_session.originate(session, "sofia/default/1235@conference.freeswitch.org", 15);
var isAnswered = new_session.waitForAnswer(10000);
// its been 10 seconds (isAnswered == false) or a real answer at this point (isAnswered == true)

See also

Personal tools
Community