[Freeswitch-users] Bridge 2 calls, catchup hangup and connect to 3rd party

Birgit Arkesteijn birgit at westhawk.co.uk
Thu Oct 9 06:45:24 PDT 2008


Hi David,

Thanks for your answer.

I noticed that the behaviour between
   bridge(cSession, m1Session);
and
   cSession.execute("bridge", ....);
is different.

Using the first one ("bridge") will not call the HangupHook,
using the second one ("execute"), does call the HangupHook.


However, even with the two parameters you mentioned, the first session 
hangs up. When I try to use the session in the HangupHook function, I 
get the error "Session is not active".

I tried the bridge with multiple endpoints, but after 0663 it hangs up:
cSession.execute("bridge",
     "sofia/gateway/westhawk/0663|sofia/gateway/westhawk/0661");


My questions:
01. Does anyone know how to make sure cSession remains active?

02. If I can only use cSession.execute, how do 'speak' to my endpoint 
BEFORE the call is actually being bridged?
     I tried
     cSession.execute("set", "group_confirm_key=exec");
     cSession.execute("set", "group_confirm_file=javascript person.js");
     but that keeps ringing 0663 back, even when I hang up. I had to kill
     (-9) FreeSWITCH.

03. Is my whole approach flawed?


Here is my updated JS:

function on_hangup1(hup_session, how) {
     console_log("info", "on_hangup1(): " + how + " HOOK"
         + ", name: " + hup_session.name
         + ", state: " + hup_session.state
         + ", cause: " + hup_session.cause + "\n");

     hup_session.speak("cepstral", "Diane", "Wait, we are trying to find 
the next person"); // ---> Results in error
}


var cSession = new
Session("{ignore_early_media=true,call_timeout=60}sofia/gateway/westhawk/0662");
while (cSession.ready()) {
     // The call has been answered

     cSession.execute("set", "call_timeout=60");
     cSession.execute("set", "continue_on_fail=true");
     cSession.execute("set", "hangup_after_bridge=false");
     cSession.execute("set", "ringback=%(2000,4000,440.0,480.0)")

     cSession.setHangupHook(on_hangup1);
     cSession.execute("bridge", "sofia/gateway/westhawk/0663");
}


exit();

(end of JS)


Thanks, Birgit

On 08/10/08 18:42, David Knell wrote:
> Hi Brigit,
> 
> Set
> continue_on_fail=true
> and
> hangup_after_bridge=false
> 
> should let you just continue with your script after the bridge.
> 
> Cheers --
> 
> Dave
> 
> 
>> Hi,
>>
>> I'm running FreeSWITCH 498:8901 on x86_64 GNU/Linux.
>>
>> I'm trying to get person 1 to speak to person 2, then after person 2
>> hangs up, speak to person 3, etc, etc.
>>
>>
>> So:
>> person1 -> person2
>> person1 -> person3
>> ...
>> person1 -> personN
>>
>> In between connecting person1 to the next person, I need to do some
>> admin and speak phrases to person1 and personX independently.
>>
>> Our software originates the calls, so I've chosen for RPC and JS.
>>
>> I succeed orginating a call to person1 and person2 and bridging them.
>> However, I struggle to find a way to 'catch' the hangup and make  
>> person1
>> connect to person3.
>>
>> I tried using session.setHangupHook, but the function is never called.
>>
>> Any idea how I can catch the hangup of person2 so it doesn't hangup on
>> person1, so I can connect person1 to person3?
>>
>>
>>
>> This is what I've got so far:
>>
>> function on_hangup2(hup_session, how) {
>>     console_log("info", "on_hangup2(): " + how + " HOOK"
>>         + " name: " + hup_session.name
>>         + " state: " + hup_session.state
>>         + " cause: " + hup_session.cause + "\n");
>>
>>     exit();
>> }
>>
>> function on_hangup1(hup_session, how) {
>>     console_log("info", "on_hangup1(): " + how + " HOOK"
>>         + " name: " + hup_session.name
>>         + " state: " + hup_session.state
>>         + " cause: " + hup_session.cause + "\n");
>>
>>     cSession.speak("cepstral", "Diane", "Wait we are trying to find  
>> the
>> next person");
>>     var m2Session = new Session("sofia/gateway/westhawk/0661");
>>     cSession.setHangupHook(on_hangup2);
>>     m2Session.setHangupHook(on_hangup2);
>>     bridge(cSession, m2Session);
>> }
>>
>>
>> var cSession = new
>> Session("{ignore_early_media=true,call_timeout=60}sofia/gateway/ 
>> westhawk/0662");
>> while (cSession.ready()) {
>>     // The call has been answered
>>
>>     cSession.speak("cepstral", "Diane", "Wait we are trying to find  
>> the
>> next person");
>>     var m1Session = new Session("sofia/gateway/westhawk/0663");
>>     cSession.setHangupHook(on_hangup1);
>>     m1Session.setHangupHook(on_hangup1);
>>     bridge(cSession, m1Session);
>> }
>>
>> (end js).
>>
>>
>> I tried
>> cSession.bridge("sofia/gateway/westhawk/0663|sofia/gateway/westhawk/ 
>> 0661");
>> but that didn't work either.
>>
>> Thanks, Birgit




More information about the FreeSWITCH-users mailing list