Sending manager events from app_voicemail.c

I need to get something to trigger actions on a remote application from inside the app_voicemail.c module(e.g. the user choose to reply a certain message from inbox).
I have chosen to use manager events. I had to add C code inside the module for this to work. And it works. The events reach my app just fine. But there is an issue I am concerned about this solution. I cannot make sure that the other app has enough time to do the action requested by the event before the message gets recorded. So I tried to use a channel variable to get things synchronized. When the external process finishes, it will set the channel var to a predefined value. I’ve made a small function that loops for a limited number of times (say 10 times) and sleeps a few millis in between (say 500 or 1000). The external process should do the job pretty quick so in most of the cases this loop should be very short.
I see the loop executing, I see my external app trying to set the channel var (using manager api), but on the asterisk server I cannot see the var changing. So the loop finishes without getting confirmation from the cannel var.
My questions here are:

  1. Is there a better way to do this?
  2. Is there some protection set by default on the channel that prevent the local variables to be changed while I am inside the Voicemail app?
  3. Am I using the right “tools” for setting the channel var? (pbx_builtin_getvar_helper in C and SetVarAction(channel … on java)?

I am using Asterisk 1.2.5. I will double check the SetVarAction to see if it does what it is supposed to do.


The ast_safe_sleep line didn’t get executed on the tests I have performed. :smiley: So it took way too little to loop. Now I only have to tweak the right amount for the sleep period.
Nevertheless if anyone thinks a better solution to my problem exists, please let me know.