Hi,
Debug("Got a route=>"+route+", Let the network play the ringtone...");
leg_a.Execute("ring_ready", "");
Debug("Creating the new session...");
ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway}
if (leg_b.Ready())
{
Debug("Session_B ready!");
string fsuuid_b = leg_b.GetVariable("uuid");
Debug("Waiting for B-Leg to answer and A-Leg not to hangup...");
while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ }
if (leg_b.answered())
{
Debug("...B-Leg is answered");
AnswerCall(leg_a);
while (!leg_a.answered()) { }
Debug("...A-Leg is answered");
// ****** BRIDGE SHOULD BE HERE ******
Debug("As long as both legs are Ready(), we wait......");
while (leg_b.Ready() && leg_a.Ready())
{
Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED
Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED
}
Debug("There is one leg no longer ready...");
if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");}
if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");}
}
else
{
Debug("A-Leg aborted while dialing...");
}
if (leg_b.Ready())
{
Debug("B-Leg still here, so hanging up B-Leg...");
leg_b.Hangup("NORMAL_CALL_CLEARING");
leg_b.destroy();
}
}
else
{
string obCause = leg_b.hangupCause();
leg_a.HangUp(obCause);
Debug("Route failed with: "+obCause);
}
return true;
Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this:
leg_a.sleep(1000, 0);
string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid()));
Debug("apiResult="+apiResult);
The console log shows "+OK {guid of leg_a}
but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge.
I have checked without bridge to check if codecs are the the same and they both are PCMU 8000.
Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work.
note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...
Mike.