Hi list I plan to implement a prepaid solution where the system needs to check for remaining credit periodically during a call. The reason for this is that this is a system where the credit pool can be used simultaneously by more people, and not only for calling. I have a problem figuring how to be able to run logic while a call is in progress. The L(x:y:z) option to Dial() is good, but not quite what I need. In both the dialplan an an AGI the Dial command blocks, so what do I do? I have not yet tried a multi-threaded AGI, but assume the possibility of success with that scenario to be slim... Ideally; I want to code things like this: Fetch cost of requested call; # The reserve functions also supplies total remaining credit unless (Reserve credit for N seconds) exit with message; INITIATE CALL; If answered { while(1) { Wait for N-x seconds; Reserve credit for N seconds; if (close to credit limit) PLAY WARNING BEEP; else if (out of credit) EXIT WITH MESSAGE; } } hangup_trap: Commit credit based on actual call length; EOF I realize that this probably needs to be done as a combination of dialplan logic and AGIs, but my main concern is the ability to 1) send sound to the caller of an ongoing call 2) retain control so the call can be terminated based on a timer (or whatever) Any tips would be greatly appreciated! Thanks in advance. -- Eivind Trondsen "People are destined to be party animals, and the technology will follow" - Linus Torvalds
On Wed, 2005-07-20 at 10:49 +0200, Eivind Trondsen wrote:> Hi list > > I plan to implement a prepaid solution where the system needs to check for > remaining credit periodically during a call. The reason for this is that this > is a system where the credit pool can be used simultaneously by more people, > and not only for calling. > > I have a problem figuring how to be able to run logic while a call is in > progress. The L(x:y:z) option to Dial() is good, but not quite what I need. > In both the dialplan an an AGI the Dial command blocks, so what do I do? > > I have not yet tried a multi-threaded AGI, but assume the possibility of > success with that scenario to be slim... > > Ideally; I want to code things like this: > > Fetch cost of requested call; > # The reserve functions also supplies total remaining credit > unless (Reserve credit for N seconds) exit with message; > INITIATE CALL; > If answered { > while(1) { > Wait for N-x seconds; > Reserve credit for N seconds; > if (close to credit limit) PLAY WARNING BEEP; > else if (out of credit) EXIT WITH MESSAGE; > } > } > > hangup_trap: > Commit credit based on actual call length; > > EOF > > I realize that this probably needs to be done as a combination of dialplan > logic and AGIs, but my main concern is the ability to > > 1) send sound to the caller of an ongoing call > 2) retain control so the call can be terminated based on a timer (or whatever) > > Any tips would be greatly appreciated! Thanks in advance.Use the manager API to terminate the call if their credit reaches zero, connect and process active channels on an regular basis (as needed), use the AGI to reduce the credit by the needed amount at the end of the call (from h extension, or g option to Dial). Regards, Adam -- -- Adam Goryachev Website Managers Ph: +61 2 9345 4395 adam@websitemanagers.com.au Fax: +61 2 9345 4396 www.websitemanagers.com.au
Eivind, I was thinking of doing something similar and came across a slight variation of your problem. While testing a home-grown prepaid solution, a beta-"friend" informed me that he detected a problem I could run into, which I will attempt to describe below. Say he makes a call and is informed he has 30 minutes left on the call. After, say, 9 minutes, he hook flashes in order to get the second line (just like call-waiting/three-way-calling feature). At this point he can me a second call where he MAY be informed accurately that now he has 21 minutes left. The problem is that the first call has not hung up so he is not necessarily informed of the accurate time left for the second call. Additionally, say he speaks for another 10-15 minutes (regardless of whether or not he hook- flashes again to do three-way calling) and then returns to the first call. At that point he can continue on the first call for the original full 30 minutes, even though he consumed (potentially) 40-45 minutes. Has anyone worked some solution for this (as well as Eivind's problem) in all the prepaid solutions out there I see constantly on the list? Thanks, Waldo On Jul 20, 2005, at 4:49 AM, Eivind Trondsen wrote:> Hi list > > I plan to implement a prepaid solution where the system needs to > check for > remaining credit periodically during a call. The reason for this is > that this > is a system where the credit pool can be used simultaneously by > more people, > and not only for calling. > > I have a problem figuring how to be able to run logic while a call > is in > progress. The L(x:y:z) option to Dial() is good, but not quite what > I need. > In both the dialplan an an AGI the Dial command blocks, so what do > I do? > > I have not yet tried a multi-threaded AGI, but assume the > possibility of > success with that scenario to be slim... > > Ideally; I want to code things like this: > > Fetch cost of requested call; > # The reserve functions also supplies total remaining credit > unless (Reserve credit for N seconds) exit with message; > INITIATE CALL; > If answered { > while(1) { > Wait for N-x seconds; > Reserve credit for N seconds; > if (close to credit limit) PLAY WARNING BEEP; > else if (out of credit) EXIT WITH MESSAGE; > } > } > > hangup_trap: > Commit credit based on actual call length; > > EOF > > I realize that this probably needs to be done as a combination of > dialplan > logic and AGIs, but my main concern is the ability to > > 1) send sound to the caller of an ongoing call > 2) retain control so the call can be terminated based on a timer > (or whatever) > > Any tips would be greatly appreciated! Thanks in advance. > > -- > Eivind Trondsen > > "People are destined to be party animals, > and the technology will follow" > - Linus Torvalds > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users@lists.digium.com > http://lists.digium.com/mailman/listinfo/asterisk-users > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >
> > 1) send sound to the caller of an ongoing call > > 2) retain control so the call can be terminated based on a timer (or > > whatever) > > > > Any tips would be greatly appreciated! Thanks in advance. > > Use the manager API to terminate the call if their credit reaches zero, > connect and process active channels on an regular basis (as needed), use > the AGI to reduce the credit by the needed amount at the end of the call > (from h extension, or g option to Dial).Thanks Adam. This helps some, but I'm still not sure how you mean for me to acheive 1). I would have to perform a Dial-command no matter what, so I guess I would have to make an interruption from the manager API, but I don't manage to find a command that will acomplish that. Regards -- Eivind Trondsen "People are destined to be party animals, and the technology will follow" - Linus Torvalds