Asterisk AGI with C problems

905 Views Asked by At

EHLO everybody

I am into AGI with C language, and after a while I got a issue. When I playback a file to the channel with GET DATA (and other AGI commands), I need to apply a sleep function so this can be played and the user has time to hear it.

My partial code is like this:

 char line[80];
 int digit;
 setlinebuf(stdout);
 setlinebuf(stderr);
 printf("ANSWER\n");  
 printf("GET DATA en/pbx-transfer 5000 4 \n"); 
 sleep(3);
 printf("CHANNEL STATUS\n");
 printf("HANGUP");

Asterisk shows me a warning about my use of sleep() like this:

The FD we were waiting for has something waiting. Waitfordigit returning numeric 1

Why is this happening?

1

There are 1 best solutions below

4
On

First of all - no need reinvent the Wheel. There are more then one AGI interface implemntation for c/c++

You have no use sleep,threads,waits etc inside agi script.

AGI architecture is example of blocking by STD input. Just wait for input(READ from STD) and it will return you info when it ready.

If you use it, such message is normal and expected. You can use non-blocking versions of sleep.

ALSO you have not use GET DATA if you not need DATA. You can use STREAM