I am developing FreeSwitch Javascript capability to emulate some functionality 
that is currently provided by a Dialogic based proprietary system running on 
Microsoft Windows, originally using ISDN interfaces and then ported to Sip 
based VoIP capability.
This system uses external post-processing code that processes "event" type data 
for billing and other purposes and I need to provide equivalent event data.
As part of this effort, I need a counter that is guarantied unique when there 
is a possibility that multiple calls may access the counter. The proprietary 
code, this unique counter is provided by using InterlockedIncrement().

Looking at the available JavaScript code, it appears that using 
getGlobalVariable() and setGlobalVariable() as described in the SetGlobalVar 
Wiki page would allow me to do this as long as I was willing to allow holes in 
the count.

However, I decided to look at the code to see exactly what was being done to 
implement this. I found was that there was no code at all to implement the 3rd 
optional parameter.

I would like to implement this capability but extend the capability to truly 
provide a unique counter. To accomplish this, support must be provided by the 
switch core.

I would like to provide a new routine into switch_core.c:
<Following is the text for switch_core.h>
/*! 
  \brief Conditionally add a global variable to the core
  \param varname the name of the variable
  \param value the value of the variable
  \param val2 the value of the variable to verify against
  \     If the global did not exist and val2=="", add global with value, return 
true
  \     If the global exists with the value of val2, replace it, return true
  \     If the global exists with a value other than val2, return false
*/
SWITCH_DECLARE(switch_bool_t) switch_core_set_var_conditional(_In_z_ const char 
*varname, _In_opt_z_ const char *value, _In_opt_z_ const char *val2);

Then the code in mod_spidermonkey.c can be modified to use this new switch core 
capability.

Note: I have implemented this in my local version and have tested it.

_______________________________________________
FreeSWITCH-dev mailing list
FreeSWITCH-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org

Reply via email to