<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">The call control engine + rating engine already supports multiple parallel prepaid sessions per user, all calls stop when the balance reaches zero.<div><br></div><div>What do you try to achieve?</div><div><br></div><div>Adrian</div><div><br><div><br></div><div><div><div><div>On Jun 18, 2010, at 4:56 PM, Magnus Burman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi guys,<div><br></div><div>To get a more flexible credit control when running several concurrent calls on the same user I'm trying to add some functionality to the call control module.</div><div><br></div><div>Basically what I'm trying to do is set a low time limit, such as 60 seconds, and when the timer runs out send a new getCallLimit, until the call ends either by a return of 0 or by hangup.</div>

<div><br></div><div>I've been trying to do this by adding a new getCallLimit in the Call.__expire method in sip.py.&nbsp;</div><div><br></div><div><div><div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp;def __expire(self):</font></div>

<div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rating = RatingEngineConnections.getConnection(self)</span></div><div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;rating.getCallLimit(self).addCallbacks(callback=self._reinit_simple_calllimit, errback=self._start_error)</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;"""</font></div><div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.expired = True</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.application.clean_call(self.callid)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;self.end(reason='call control', sendbye=True)</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;"""</font></div></div></div><div><br></div><div>In <font class="Apple-style-span" face="'courier new', monospace">_reinit_sample_calllimit</font> I mimic <font class="Apple-style-span" face="'courier new', monospace">_start_finish_calllimit</font> in a lot of ways, trying different timer combinations. I've tried with cancel followed by a new setup, I've tried delay, I've tried reset, I've tried manually doing a new ReactorTimer and all of the above!</div>

<div><br></div><div>I get the MaxSessionTime call to work, but I fail with the timer somehow. __expire is never called again after the first time, and the call is never interrupted.</div><div><br></div><div>Anyone with tips? At this point I'm about to dive into the twisted framework and reactors, but any hints are much appreciated!</div>

<div><br></div><div>Cheers,<br>Magnus</div>
_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>http://lists.opensips.org/cgi-bin/mailman/listinfo/users<br></blockquote></div><br></div></div></div></body></html>