I want to call an extn, then when they pick up connect them to another existing channel - later I'll run this via event_socket, but for now I'm doing it in javascript (I want to do database updates before and after attempting the connection.)

As far as I can see, I have two options, and I'm interested in which is better, and more importantly - how to get either of them working!


1) Create the new session, then intercept the existing channel:

var NewSession = new Session('{ignore_early_media=true,hangup_after_bridge=false}user/12610@domainname.com');
NewSession.execute('intercept', 'cafc3449-9000-47bc-8b28-257748d7ec40');

The newSession phone rings and on pickup both channels get hung up. The ExistingChannel gives a call status in the CLI of [DESTINATION_OUT_OF_ORDER]


2) Create the new session, and create a session object for the existing session and bridge them:

var NewSession = new Session('{ignore_early_media=true,hangup_after_bridge=false}user/12610@domainname.com');
var ExistingSession = new Session('cafc3449-9000-47bc-8b28-257748d7ec40');
bridge(ExistingSession, NewSession);

(This has a debug message saying "BRIDGE THREAD DONE", but not much else that seems unusual.)

The sound files that are playing in ExistingSession continue, and after about 10sec A notice appears in the CLI indicating a session.hungup event has fired, but both phones remain on the hook and hanging up either doesn't affect the other.


Cheers,
Fraser