[Asterisk-Users] RE: question about prepaid app_prepaid
Storm D. J. Petersen
stormp at telus.net
Thu Jun 10 19:19:47 MST 2004
Hi,
As you asked, I have included my diff to what I did for the DIAL command. I
probably didn't stick to some * pre-agreed standard of coding or something,
so if these things offend you then I suggest that you close your eyes. :)
The biggest thing to consider when you are doing a prepaid system is, what
if the person with the same account in/out calls twice? I chose, for now,
just to keep track in a database if an account is in use or not. Only
allowing calls to be placed/answered when the account was not engaged with
another call. It was that fastest way to implement my credit system. This
way is too limited for my liking and wanted to look into more on a way to
check in the scheduler to track credits used in real-time to allow multiple
calls out on the same account. I haven't had time to look into this in much
detail, but I am certain I can hack it into the Asterisk system - if not it
could always be done with an external daemon.
Let me know if anyone has thoughts about this.
Hope this helps people.
Storm.
*** app_dial.c 2004-03-18 16:09:14.000000000 -0800
--- ../../app_dial.c 2004-06-10 17:41:14.044176497 -0700
***************
*** 67,72 ****
--- 67,73 ----
" 'P[(x)]' -- privacy mode, using 'x' as database if provided.\n"
" 'g' -- goes on in context if the destination channel hangs up\n"
" 'A(x)' -- play an announcement to the called party, using x as
file\n"
+ " 'B(x)' -- Timeout in 'x' seconds after call was bridged.\n"
/* CHANGE: Storm Petersen */
" In addition to transferring the call, a call may be parked and then
picked\n"
"up by another user.\n"
" The optional URL will be sent to the called party if the channel
supports\n"
***************
*** 360,365 ****
--- 361,367 ----
struct localuser *u;
char info[256], *peers, *timeout, *tech, *number, *rest, *cur;
char privdb[256] = "", *s;
+ char szBrdgTO[256] = "", *s2; // CHANGE: buffer to
store Bridging Time out. Storm Petersen */
char announcemsg[256] = "", *ann;
struct localuser *outgoing=NULL, *tmp;
struct ast_channel *peer;
***************
*** 380,385 ****
--- 382,390 ----
struct varshead *headp, *newheadp;
struct ast_var_t *newvar;
int go_on=0;
+ time_t myt;
+ int iBrdgTO=0; /* CHANGE: Time out after
call bridged. Storm Petersen */
+
if (!data) {
ast_log(LOG_WARNING, "Dial requires an argument
(technology1/number1&technology2/number2...|optional timeout)\n");
***************
*** 416,422 ****
ast_log(LOG_WARNING, "Dial argument takes format
(technology1/number1&technology2/number2...|optional timeout)\n");
goto out;
}
!
if (transfer) {
/* XXX ANNOUNCE SUPPORT */
--- 421,449 ----
ast_log(LOG_WARNING, "Dial argument takes format
(technology1/number1&technology2/number2...|optional timeout)\n");
goto out;
}
!
! /*
! ** CHANGE: Added by Storm Petersen
! ** TIME OUT AFTER CALL WAS BRIDGED.
! */
! if ((s = strstr(data, "B("))) {
! /* Timeout after Bridging */
! strncpy(szBrdgTO, s + 2, sizeof(szBrdgTO) - 1);
! s2 = szBrdgTO;
! /* Copy the timeout string */
! while(*s2 && (*s2 != ')'))
! s2++;
! if (*s2 == ')')
! {
! *s2 = '\0';
! iBrdgTO = atoi(szBrdgTO) + 1;
! }
! else {
! ast_log(LOG_WARNING, "Bridge timeout lacking
')'\n");
! iBrdgTO = 0;
! }
! }
!
if (transfer) {
/* XXX ANNOUNCE SUPPORT */
***************
*** 703,708 ****
--- 730,746 ----
// Ok, done. stop autoservice
res2 = ast_autoservice_stop(chan);
}
+
+ /*
+ ** CHANGE: Added by Storm Petersen
+ ** Set TimeOut After call was Bridged.
+ */
+ if(iBrdgTO)
+ {
+ time(&myt);
+ chan->whentohangup = myt + iBrdgTO;
+ }
+
res = ast_bridge_call(chan, peer, allowredir_in,
allowredir_out, allowdisconnect);
if (res != AST_PBX_NO_HANGUP_PEER)
-----Original Message-----
From: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com]On Behalf Of usedcanon
Sent: Thursday, June 10, 2004 5:08 PM
To: asterisk-users at lists.digium.com
Subject: RE: [Asterisk-Users] FW: question about prepaid app_prepaid
I would be interested to share ideas, if you have guidence to offer I would
be greatful
Umar.
-----Original Message-----
From: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com]On Behalf Of Storm D. J.
Petersen
Sent: 11 June 2004 00:48
To: asterisk-users at lists.digium.com
Subject: RE: [Asterisk-Users] FW: question about prepaid app_prepaid
Hi, I found that the PREPAID system didn't disconnect proper and tracked
time from when you dialed not when your phone made connection. I ended up
making my own system and had to modify the Dial app.
S.
-----Original Message-----
From: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com]On Behalf Of Umar Sear
Sent: Thursday, June 10, 2004 9:02 AM
To: asterisk-users at lists.digium.com
Subject: Re: [Asterisk-Users] FW: question about prepaid app_prepaid
Thanks to the lack of documentation, I decided to
write my own AGI script (working but no where near
complete)
Look forward to replies and guidence on this topic.
Umar.
--- Yang Tao <yang at er21.com> wrote: >
>
>
>
> Hi,
>
> I have compiled and installed app_prepaid module.
> But have problem when
> connect to postgres database. I guess so because
> after key in card number,
> it always play prepaid-no-aaa voice file.
>
> Anyone succeeded in configuring the app_prepaid for
> prepaid calling service
> for asterisk? Please help.
>
>
>
> Ps: where can I view the log file for this module.
>
>
>
> Thanks.
>
>
>
> Tom
More information about the asterisk-users
mailing list