[Freeswitch-users] How to bridge 2 sessions with Javascript?
Brian West
brian.west at mac.com
Thu Mar 27 19:55:25 PDT 2008
Revised script:
session1 = new Session();
session1.originate(session1, "{ignore_early_media=true}sofia/gateway/
asterlink.com/19184249378");
session2 = new Session();
session2.originate(session2, "sofia/gateway/asterlink.com/19184238080");
bridge(session1, session2);
session.hangup();
while (session1.ready() && session2.ready()) { }
You don't need waitForAnswer because the ignore_early_media=true
performs that automatically for you so it won't return till you
answer. And you don't want the ignore_early_media on the second leg
otherwise you get NO ringback and its just silent till the other end
is answered.
/b
On Mar 27, 2008, at 9:10 PM, Nicolas Brenner wrote:
> Hello everybody again,
>
> First of all I want to say thanks to the people on this list and on
> IRC, I'm really surprised (in a very good way) of the help I've
> received.
>
> Now to my problem: I'm trying to bridge two SIP calls together with a
> JS script, and to achieve it, I'm did the following:
> - created a dialplan entry for extension 500 which calls js script
> - created a js script with the following code:
>
> // Create new_session
> session1 = new Session();
> session1.originate(session,
> "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/
> 005624949458");
> session1.waitForAnswer(10000);
>
> new_session = new Session();
> new_session.originate(session,
> "{ignore_early_media=true}sofia/gateway/sip.sipdiscount.com/
> 0056979039388",
> 30);
> new_session.waitForAnswer(10000);
>
> // IF everybody is ready, then bridge our current session & the
> new_session
> if (session1.ready() && new_session.ready()) {
> console_log("info", "Interoligofrenico!\n");
> bridge(session1, new_session);
> }
>
> // hangup when done
> session1.hangup();
> new_session.hangup();
>
> When I register with extension 1000 using a softphone and dial
> extension 500, the code above successfully creates the two new
> sessions, makes the calls in order, and supposedly bridges the
> sessions (I get no error about the bridge on the console, and I get
> the log text too), but I get no audio on either end. Anybody know
> what's wrong with the code?
>
> Btw, how can I originate a call to a configure extension? All examples
> on the wiki use the 'sofia syntax', should I just use
> sofia/default/1001 for example?
>
> Thanks!
>
> Nicolas
>
> _______________________________________________
> Freeswitch-users mailing list
> Freeswitch-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
More information about the FreeSWITCH-users
mailing list