VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
msc at freeswitch.org Guest
|
Posted: Mon Mar 30, 2009 5:16 pm Post subject: [Freeswitch-users] Javascript, Hanguphooks, CDRs and User V |
|
|
Are logging both a- and b-legs? Just curious what your setup is.
-MC
2009/3/30 Keith Laaks <keithl@voxtelecom.co.za (keithl@voxtelecom.co.za)>
|
|
Back to top |
|
|
anthony.minessale at g... Guest
|
Posted: Mon Mar 30, 2009 5:19 pm Post subject: [Freeswitch-users] Javascript, Hanguphooks, CDRs and User V |
|
|
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 <keithl@voxtelecom.co.za (keithl@voxtelecom.co.za)>
--
Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400 |
|
Back to top |
|
|
keithl at voxtelecom.c... Guest
|
Posted: Tue Mar 31, 2009 6:43 am Post subject: [Freeswitch-users] Javascript, Hanguphooks, CDRs and User V |
|
|
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:anthony.minessale@gmail.com]
Sent: 31 March 2009 00:13
To: freeswitch-users@lists.freeswitch.org
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 <keithl@voxtelecom.co.za (keithl@voxtelecom.co.za)>
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
Freeswitch-users@lists.freeswitch.org (Freeswitch-users@lists.freeswitch.org)
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:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400 |
|
Back to top |
|
|
anthony.minessale at g... Guest
|
Posted: Tue Mar 31, 2009 8:15 am Post subject: [Freeswitch-users] Javascript, Hanguphooks, CDRs and User V |
|
|
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 <keithl@voxtelecom.co.za (keithl@voxtelecom.co.za)>
Quote: |
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:anthony.minessale@gmail.com (anthony.minessale@gmail.com)]
Sent: 31 March 2009 00:13
To: freeswitch-users@lists.freeswitch.org (freeswitch-users@lists.freeswitch.org)
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 <keithl@voxtelecom.co.za (keithl@voxtelecom.co.za)>
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
Freeswitch-users@lists.freeswitch.org (Freeswitch-users@lists.freeswitch.org)
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:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org (Freeswitch-users@lists.freeswitch.org)
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:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400 |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|