[Freeswitch-users] .NET managed code - call count

Dave R. Kompel drk at drkngs.net
Thu Mar 7 07:08:43 MSK 2013


The reason it's a public is you may need to decrement it outside of the class, like from API, in a hangup_hook or other place.   
   
--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 19:57:09 -0800
Subject: Re: [Freeswitch-users] .NET managed code - call count

I implemented "public static" option for now. I will let you know what happens.  

  
But even "private static" option I had was also sharing call counts across different calls. I am not sure whether logic is buggy or not.  

  
I -- the variable in hangup hook function. Is that OK?  

  
Thanks.

  
On Wed, Mar 6, 2013 at 9:01 PM, Dave R. Kompel <drk at drkngs.net> wrote:
    
  
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.  

  
   
 
_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
consulting at freeswitch.org
http://www.freeswitchsolutions.com




Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


      
   
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130306/0a6bc066/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list