[Freeswitch-users] .NET managed code - call count
Dave R. Kompel
drk at drkngs.net
Thu Mar 7 06:01:32 MSK 2013
There is not any one specific method of keeping a call count in a managed module that is correct. It all depends on what you are doing in the code.
Using a private is normally a bad idea since if you are doing this from an IAppPlugin interface, and you transfer the call, that instance will go away, and you will never decrement it.
If every call is going through this app, then I would use a public static int, put the whole thing in a try-catch-finally block and decrement the count in the finnaly block, to make sure it executes.
If there is a more complex where the call will get out of your code and still be up then use a static Hashtable<Guid>, and put the sessions uuid in the hash, and have ether an event consumer loop for a channel_hangup_complete remove it, the count of the hashtable should always be right, or have an API in the same module IApiPlugin, that you call to remove the uuid and set the channels API_HANGUP_HOOK so it gets called whenever the channel goes away.
--Dave
_____
From: Malay Thakershi [mailto:mthakershi at gmail.com]
To: FreeSWITCH Users Help [mailto:freeswitch-users at lists.freeswitch.org]
Sent: Wed, 06 Mar 2013 11:53:13 -0800
Subject: [Freeswitch-users] .NET managed code - call count
Hello,
I have a .NET managed module handling calls transferred to it via dial plan.
Now, I would like to maintain concurrent call count and decline the call if it has reached certain limit.
What I do is, have a static variable to track this.
private static int mIntCurCalls = 0;
Then, when Run() is executed, I mIntCurCalls++ after answering the call.
I perform check if mIntCurCalls > "max allowed calls" then I play a message and hangup.
I mIntCurCalls-- this when call is hung up.
Since last few days users have been complaining they get "busy" or "number not available" when dialing toll-free number.
However, I don't see them getting the message that I have in the code.
Is the method of keeping call count correct?
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130306/68003eb0/attachment.html
Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users
mailing list