if you set the channel variable 'session_in_hangup_hook=true' early in the
call, the session will be present in your script.



2009/3/31 Keith Laaks <[email protected]>

>  Hi,
>
>
>
> Here is what I am trying to accomplish:
>
>
>
> //--- completecall.js trigged via api_hangup_hook ----
>
>
>
> use("CURL");
>
>
>
> const loglevel='notice';
>
> var uuid = request.getHeader("Core-UUID");
>
> var billmsec = request.getHeader("billmsec");
>
> var urlrequest = "UUID=" + uuid + "&billmsec=" + billmsec;
>
>
>
> function reply_callback(string, arg) {
>
>   string = string.substring(string.search("API")+3);
>
>   string = string.substring(0,string.search("<"));
>
>   var splits = string.split("~");
>
>   var i = 0;
>
>   var length = splits.length;
>
>   for (i=0; i < length; i++) {
>
>     var fv=splits[i].split("=");
>
>     console_log(loglevel, "setting: " + fv[0] + " = " + fv[1] + "\n");
>
>     //session.setVariable(fv[0],fv[1]); // Cant use set here as the session
> is dead by now - the call has been terminated
>
>   }
>
>   return true;
>
> }
>
>
>
> var curl = new CURL();
>
> console_log(loglevel,"-- completecall.js ->" + url + "?" + urlrequest +
> "\n");
>
>
>
> var env = request.dumpENV("text");  // debug
>
> console_log("ENV:\n", env + "\n"); // debug
>
>
>
> curl.run("POST", "http://127.0.0.1:10502/rate";, urlrequest,
> reply_callback, "CBrate\n");
>
> //returns string like <sometag>APIcharge=10.20</sometag>
>
>
>
> exit();
>
>
>
>
>
> So the trick is that I am accessing an external system via CURL where the
> call rate is calculated and returned (based on the call duration and uuid).
>
> Now I need to use a ‘setVariable’ to get it back as one of the parameters
> that the cdr module can write out for me.
>
> Note that in the above, the external system will return ‘charge=value’.
>
> I need to set the variable ‘charge’ to the value in ‘value’.
>
> Then using the config below, ‘charge’ can be written out as one of the cdr
> fields.
>
>
>
>
>
> <configuration name="cdr_csv.conf" description="CDR CSV Format">
>
>   <settings>
>
>     <!-- 'cdr-csv' will always be appended to log-base -->
>
>     <!--<param name="log-base" value="/var/log"/>-->
>
>     <param name="default-template" value="def"/>
>
>     <!-- This is like the info app but after the call is hung up -->
>
>     <param name="debug" value="true"/>
>
>     <param name="rotate-on-hup" value="true"/>
>
>     <!-- may be a b or ab -->
>
>     <param name="legs" value="a"/>
>
>   </settings>
>
>   <templates>
>
>      <template
> name="def">"${accountcode}","${billsec}","${charge}","${sip_req_user}","${hangup_cause}","${uuid}","${bleg_uuid}"</template>
>
>   </templates>
>
> </configuration>
>
>
>
>
>
>
>
> Best Regards
>
>
>
> Keith
>
>
>
>
>
> *From:* Anthony Minessale [mailto:[email protected]]
> *Sent:* 31 March 2009 00:13
> *To:* [email protected]
> *Subject:* Re: [Freeswitch-users] Javascript, Hanguphooks,CDRs and User
> Variables.
>
>
>
> in your script called via api_hangup_hook:
>
> var env = request.dumpENV("text");
>
> consoleLog("info", env);
>
> all those vars are there for you, you can get the individually with
> var hval = request.getHeader("some_header");
>
>  2009/3/30 Keith Laaks <[email protected]>
>
> Hi,
>
>
>
> I have an application where my Javascript hanguphook code calculates a
> value (e.g. the cost of the call which can only be calculated post hangup)
> and I need to have that value appear as a field in the cdrs.
>
>
>
> As the ‘session’ object is no longer available for javascript logic post
> hangup, I can’t figure out how to ‘set’ a user variable post hangup, such
> that it can be written to the cdr when the state changes from  CS_HANGUP ->
> CS_REPORTING.  Maybe it’s just not possible……? It would be a pity to have to
> resort to writing out cdrs from the javascript itself and duplicating what
> fs does so well already.
>
>
>
> Any advice / suggestions would be appreciated.
>
>
>
> Best Regards
>
>
>
> Keith
>
>
>
>
> _______________________________________________
> Freeswitch-users mailing list
> [email protected]
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
>
>
> --
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
>
> AIM: anthm
> MSN:[email protected] <msn%[email protected]>
> GTALK/JABBER/PAYPAL:[email protected]<paypal%[email protected]>
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:[email protected] <sip%[email protected]>
> iax:[email protected]/888
> googletalk:[email protected]<googletalk%3aconf%[email protected]>
> pstn:213-799-1400
>
> _______________________________________________
> Freeswitch-users mailing list
> [email protected]
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>


-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:[email protected] <msn%[email protected]>
GTALK/JABBER/PAYPAL:[email protected]<paypal%[email protected]>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:[email protected] <sip%[email protected]>
iax:[email protected]/888
googletalk:[email protected]<googletalk%3aconf%[email protected]>
pstn:213-799-1400
_______________________________________________
Freeswitch-users mailing list
[email protected]
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org

Reply via email to