[Freeswitch-users] Javascript, session_in_hangup_hook and api_hangup_hook

Roman_ lists at ione.ch
Tue Mar 3 10:16:17 MSK 2015


Hi,

I have been trying to run a javascript on hangup in my dialplan, where I
need access to the session in the script, but I cannot get it to work.
Searching the mailing list also has not revealed anything pertinent (except
that it *should* work for at least lua and javascript). My (partial)
dialplan looks as follows:

<action application="set" data="session_in_hangup_hook=true"/>
<action application="set" data="api_hangup_hook=jsrun
/etc/freeswitch/scripts/script.js"/>
<action application="bridge" data="..."/>

The javascript gets called reliably, however, the session object is not
available. If I try to access it, I get an error:

2015-03-02 22:19:22.260371 [ERR] script.js:7 Exception: TypeError: Object
#<error> has no method 'getVariable' (near: "var total_billed =
session.getVariable("nibble_total_billed");")

So it seems the session object isn't actually a session, but some error?
Just printing the session object to the console will output "false".

Is there something I am missing here? Has anybody managed to use the session
object in a javascript script in the api hangup hook?

I am using FreeSWITCH Version 1.4.15-1~64bit (-1 64bit) (the debian
packages).

Any help would be greatly appreciated.

Thanks and best regards,

Roman




--
View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Javascript-session-in-hangup-hook-and-api-hangup-hook-tp7596149.html
Sent from the freeswitch-users mailing list archive at Nabble.com.



Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list