[Freeswitch-users] How to bridge 2 sessions with Javascript?

Anthony Minessale anthmct at yahoo.com
Fri Mar 28 08:16:50 PDT 2008


and just to point it out, you can also do:

session1 = new Session();
session1.originate(session1, "{ignore_early_media=true}sofia/gateway/ 
asterlink.com/19184249378");

session1.execute("bridge", "sofia/gateway/asterlink.com/19184238080");

or even better

// this will transfer the channel into the dialplan and end the script
// thus reducing overhead of leaving JS open.
session1.execute("transfer", "19184238080");



 
Anthony Minessale II

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

AIM: anthm
MSN:anthony_minessale at hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org
pstn:213-799-1400


----- Original Message ----
From: Brian West <brian.west at mac.com>
To: freeswitch-users at lists.freeswitch.org
Sent: Thursday, March 27, 2008 9:55:25 PM
Subject: Re: [Freeswitch-users] How to bridge 2 sessions with Javascript?

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


_______________________________________________
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






      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20080328/d5c4f17f/attachment-0002.html 


More information about the FreeSWITCH-users mailing list