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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Nov 15 15:57:25 CST 2010


branch "ami-route" has been created
        at  6a99b4f89401d3b3a26c06bbeadfd6ba0524c5d5 (commit)

- Log -----------------------------------------------------------------
commit 6a99b4f89401d3b3a26c06bbeadfd6ba0524c5d5
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Nov 15 15:32:13 2010 -0600

    make routeSession use AMI.

diff --git a/slice b/slice
index df22de4..0c62939 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit df22de4cdfa237ab7cbabbc8af895de73f554a9a
+Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index e770b81..5b2823a 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -47,6 +47,43 @@ using namespace AsteriskSCF::SessionCommunications::V1;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::SIP::V1;
 
+class RouteSessionCookie : public Ice::LocalObject
+{
+public:
+    RouteSessionCookie(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
+        : mInvSession(inv_session), mTData(tdata) { }
+    pjsip_inv_session *mInvSession;
+    pjsip_tx_data *mTData;
+};
+
+typedef IceUtil::Handle<RouteSessionCookie> RouteSessionCookiePtr;
+
+class RouteSessionCallback : public IceUtil::Shared
+{
+public:
+    void routeSessionCB(const Ice::AsyncResultPtr& r)
+    {
+        SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
+        RouteSessionCookiePtr cookie = RouteSessionCookiePtr::dynamicCast(r->getCookie());
+        try
+        {
+            router->end_routeSession(r);
+        }
+        catch (DestinationNotFoundException &)
+        {
+            pjsip_inv_end_session(cookie->mInvSession, 404, NULL, &cookie->mTData);
+            pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+        }
+        catch (...)
+        {
+            pjsip_inv_end_session(cookie->mInvSession, 500, NULL, &cookie->mTData);
+            pjsip_inv_send_msg(cookie->mInvSession, cookie->mTData);
+        }
+    }
+};
+
+typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
+
 PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
     SipSessionPtr session)
     :
@@ -431,17 +468,13 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
         else
         {
             // If this is not an attended transfer we can just route the session as normally
-            mSessionRouter->routeSession(session->getSessionProxy(), destination);
+		    RouteSessionCallbackPtr cb = new RouteSessionCallback();
+		    Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::routeSessionCB);
+		    RouteSessionCookiePtr cookie = new RouteSessionCookie(inv_session, tdata);
+            mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, d, cookie);
         }
     }
-    catch (AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
-    {
-        // Destination not found is special since we can actually map it to a good response code, 404
-        pjsip_inv_end_session(inv_session, 404, NULL, &tdata);
-        pjsip_inv_send_msg(inv_session, tdata);
-        return;
-    }
-    catch (...)
+    catch (Ice::CommunicatorDestroyedException &)
     {
         // Everything else doesn't really map so they just become internal server errors
         pjsip_inv_end_session(inv_session, 500, NULL, &tdata);

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list