[SR-Users] PRE-PAY update timer

Alex Balashov abalashov at evaristesys.com
Sat May 25 01:16:12 CEST 2019


Well, the generic answer to the question of how to periodically do
something in the background is 'rtimer':

https://kamailio.org/docs/modules/5.2.x/modules/rtimer.html

This can be combined with putting dialogs in an `htable` (perhaps using
the dialog module's start/end event_routes) and walking over the
entries in a background rtimer route:

https://kamailio.org/docs/modules/5.2.x/modules/htable.html#htable.f.sht_iterator_start

Alternately, one can use jsonrpc_exec() 

https://kamailio.org/docs/modules/5.2.x/modules/jsonrpcs.html#jsonrpcs.f.jsonrpc_exec

to run 'dlg.list':

https://kamailio.org/docs/modules/5.2.x/modules/dialog.html#dlg.r.list

... and iterate over the output with the help of the 'jansson' module
(JSON parser):

https://kamailio.org/docs/modules/5.2.x/modules/jansson.html


But honestly, I'd ask yourself whether this extra layer of complexity is
truly worth it. For a lot of prepaid setups, live balance decrementing
isn't worth the bother. 

An alternate and simpler approach is to just let the call be initiated
if the balance is > 0 at the time the call is made, then deduct from the
balance when the call ends.

Yeah, it means someone's free to make a 4 hour call without the prepaid
credit to support it, and worse yet, possibly a number of 4 hour calls
initiated simultaneously. But most calls aren't like that, and from a
business perspective, is it really worth the headache of live
decrementing and all the moving parts involved?

Maybe it is, but I would at least ask the question.

-- Alex

On Fri, May 24, 2019 at 06:18:19PM +0100, Steve Bucklin wrote:

> Hello all (again),
> 
> I am looking at a 'good' method to start a call with "chunks" of time
> allocated. I wish the initial call to check a credit, and if credit is good,
> allow a small amount of time (say 30 seconds). I have enabled DIALOG and
> have looked at CNXCC, but am confused!
> 
> When the initial 30 seconds runs out, I want to authorise another 30
> seconds, etc, etc, etc. I have started to play and set a dialog timer that
> expires to a route, and then can 'return' allowing the call to continue -
> BUT was not able to reset the dialog timer to trip again after another 30
> seconds.
> 
> I tried to 'set_max_time' on cnxcc, but this did not seem to trip the event
> route upon timeout?
> 
> Does anyone have a pointer to any examples? I also am unsure of how to
> update the timer and keep a call in play!
> 
> Steve
> 
> 
> 
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/



More information about the sr-users mailing list