[asterisk-scf-commits] asterisk-scf/release/sip.git branch "ami" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Dec 2 14:03:56 CST 2010


branch "ami" has been created
        at  ff96d9728d7541e792e3a8929f66a98fa4d2768d (commit)

- Log -----------------------------------------------------------------
commit ff96d9728d7541e792e3a8929f66a98fa4d2768d
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Dec 2 14:09:02 2010 -0600

    Use AMI for calls to connectBridgedSessionsWithDestination.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 3f64de1..54361a4 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -76,6 +76,47 @@ private:
 };
 typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
 
+class ConnectSessionsCallback : public IceUtil::Shared
+{
+public:
+    ConnectSessionsCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, SipSessionPtr session)
+        : mInvSession(inv_session), mRData(rdata), mSession(session) { }
+
+    void callback(const Ice::AsyncResultPtr &r)
+    {
+        SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
+        try
+        {
+            router->end_connectBridgedSessionsWithDestination(r);
+        }
+        catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException &)
+        {
+            //XXX Put target string back in this Debug state-a-ment
+            lg(Debug) << "handleRefer() sending 404 due to destination not found for target" <<  std::endl;
+
+            pjsip_dlg_respond(mInvSession->dlg, mRData, 404, NULL, NULL, NULL);
+            return;
+        }
+        catch (const std::exception &e)
+        {
+            lg(Debug) << "handleRefer() sending 400 due to exception:  " << e.what() << std::endl;
+            pjsip_dlg_respond(mInvSession->dlg, mRData, 400, NULL, NULL, NULL);
+            return;
+        }
+        pjsip_dlg_respond(mInvSession->dlg, mRData, 200, NULL, NULL, NULL);
+        
+        Ice::Current current;
+        lg(Debug) << "handleRefer() calling session->stop(). " << std::endl;
+        mSession->stop(new ResponseCode(16), current);
+    }
+private:
+    pjsip_inv_session *mInvSession;
+    pjsip_rx_data *mRData;
+    SipSessionPtr mSession;
+};
+
+typedef IceUtil::Handle<ConnectSessionsCallback> ConnectSessionsCallbackPtr;
+
 PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
     SipSessionPtr session)
     :
@@ -595,17 +636,17 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
 
         try
         {
+            ConnectSessionsCallbackPtr cb(new ConnectSessionsCallback(inv, rdata, session));
+            Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectSessionsCallback::callback);
+
             lg(Debug) << "handleRefer() calling router connectBridgedSessions(). " << std::endl;
-            mSessionRouter->connectBridgedSessions(session->getSessionProxy(), other_session->getSessionProxy());
-            pjsip_dlg_respond(inv->dlg, rdata, 200, NULL, NULL, NULL);
-            Ice::Current current;
-            lg(Debug) << "handleRefer() calling session->stop(). " << std::endl;
-            session->stop(new ResponseCode(16), current);
+            mSessionRouter->begin_connectBridgedSessions(session->getSessionProxy(), other_session->getSessionProxy(), d);
         }
-        catch (const std::exception& e)
+        catch (const Ice::CommunicatorDestroyedException &)
         {
-            lg(Debug) << "handleRefer() sending 400 due to exception:  " << e.what() << std::endl;
-            pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+            lg(Debug) << "handleRefer() sending 503 due to communicator destruction" << std::endl;
+            pjsip_dlg_respond(inv->dlg, rdata, 503, NULL, NULL, NULL);
+            return;
         }
         pjsip_dlg_dec_lock(other_dlg);
     }
@@ -618,26 +659,16 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
         {
             PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[mModule.id];
             SipSessionPtr session = session_mod_info->getSessionPtr();
+            ConnectSessionsCallbackPtr cb(new ConnectSessionsCallback(inv, rdata, session));
+            Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectSessionsCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessionsWithDestination(). " << std::endl;
-            mSessionRouter->connectBridgedSessionsWithDestination(session->getSessionProxy(), target);
-            pjsip_dlg_respond(inv->dlg, rdata, 200, NULL, NULL, NULL);
-            Ice::Current current;
-
-            lg(Debug) << "handleRefer() calling session->stop(). " << std::endl;
-            session->stop(new ResponseCode(16), current);
-        }
-        catch (const AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
-        {
-            lg(Debug) << "handleRefer() sending 404 due to destination not found for target:  " << target << std::endl;
-
-            pjsip_dlg_respond(inv->dlg, rdata, 404, NULL, NULL, NULL);
-            return;
+            mSessionRouter->begin_connectBridgedSessionsWithDestination(session->getSessionProxy(), target, d);
         }
-        catch (const std::exception& e)
+        catch (const Ice::CommunicatorDestroyedException &)
         {
-            lg(Debug) << "handleRefer() sending 400 due to exception:  " << e.what() << std::endl;
-            pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+            lg(Debug) << "handleRefer() sending 503 due to communicator destruction" << std::endl;
+            pjsip_dlg_respond(inv->dlg, rdata, 503, NULL, NULL, NULL);
             return;
         }
     }

-----------------------------------------------------------------------


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list