In short, I’m looking to stream a message twice unless a voicemail beeps. If the voicemail beeps, then start over immediately and only play the message once.

 

Pseudo-code:

 

session.execute("avmd", "start");

session.streamFile(playbackFileName); //1st play

session.streamFile(playbackFileName); //2nd play

session.execute("hangup","ORIGINATOR_CANCEL");

 

function onDTMF(s, type, obj, arg)

{  

  if(type == "event" && session.getVariable("avmd_detect") == "TRUE")

 {

  session.execute("avmd", "stop");

  session.streamFile(playbackFileName);

  return false;

 }

 return true;
}

 

My question is what the effect and timing is of returning false or true from the onDTMF function? Does the original streamFile continue playing? Pause? end immediately? Do I have to set a variable, return false to stop the original from playing, then do my streamfile logic OUTSIDE of the onDTMF for proper flow? What happens if I never return true or false, what does it do then?

 

Thanks,
Jason