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

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


branch "ami" has been updated
       via  ae1a24529c1eb4198fb9fe248fe552e0251b942a (commit)
      from  ff96d9728d7541e792e3a8929f66a98fa4d2768d (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   53 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit ae1a24529c1eb4198fb9fe248fe552e0251b942a
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Dec 2 14:22:42 2010 -0600

    Differentiate between ConnectBridgedSessions and ConnectBridgedSessionsWithDestination.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 54361a4..6da3b59 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -76,10 +76,10 @@ private:
 };
 typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
 
-class ConnectSessionsCallback : public IceUtil::Shared
+class ConnectBridgedSessionsCallback : public IceUtil::Shared
 {
 public:
-    ConnectSessionsCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, SipSessionPtr session)
+    ConnectBridgedSessionsCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, SipSessionPtr session)
         : mInvSession(inv_session), mRData(rdata), mSession(session) { }
 
     void callback(const Ice::AsyncResultPtr &r)
@@ -87,12 +87,44 @@ public:
         SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
         try
         {
-            router->end_connectBridgedSessionsWithDestination(r);
+            router->end_connectBridgedSessions(r);
+        }
+        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<ConnectBridgedSessionsCallback> ConnectBridgedSessionsCallbackPtr;
+
+class ConnectBridgedSessionsWithDestinationCallback : public IceUtil::Shared
+{
+public:
+    ConnectBridgedSessionsWithDestinationCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, SipSessionPtr session, std::string target)
+        : mInvSession(inv_session), mRData(rdata), mSession(session), mTarget(target) { }
+
+    void callback(const Ice::AsyncResultPtr &r)
+    {
+        SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
+        try
+        {
+            router->end_connectBridgedSessions(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;
+            lg(Debug) << "handleRefer() sending 404 due to destination not found for target: "<< mTarget <<  std::endl;
 
             pjsip_dlg_respond(mInvSession->dlg, mRData, 404, NULL, NULL, NULL);
             return;
@@ -113,9 +145,10 @@ private:
     pjsip_inv_session *mInvSession;
     pjsip_rx_data *mRData;
     SipSessionPtr mSession;
+    std::string mTarget;
 };
 
-typedef IceUtil::Handle<ConnectSessionsCallback> ConnectSessionsCallbackPtr;
+typedef IceUtil::Handle<ConnectBridgedSessionsWithDestinationCallback> ConnectBridgedSessionsWithDestinationCallbackPtr;
 
 PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
     SipSessionPtr session)
@@ -636,8 +669,8 @@ 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);
+            ConnectBridgedSessionsCallbackPtr cb(new ConnectBridgedSessionsCallback(inv, rdata, session));
+            Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessions(). " << std::endl;
             mSessionRouter->begin_connectBridgedSessions(session->getSessionProxy(), other_session->getSessionProxy(), d);
@@ -659,8 +692,8 @@ 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);
+            ConnectBridgedSessionsWithDestinationCallbackPtr cb(new ConnectBridgedSessionsWithDestinationCallback(inv, rdata, session, target));
+            Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsWithDestinationCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessionsWithDestination(). " << std::endl;
             mSessionRouter->begin_connectBridgedSessionsWithDestination(session->getSessionProxy(), target, d);

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list