[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "route_replica" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Apr 24 17:13:20 CDT 2011


branch "route_replica" has been updated
       via  ae4f01805596e1d4703327ae525f00f0b20471cc (commit)
      from  d47ab831d318683075b4bb449400c6495897af5a (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   80 +++++++++++++++++++++++++++++--------------
 1 files changed, 54 insertions(+), 26 deletions(-)


- Log -----------------------------------------------------------------
commit ae4f01805596e1d4703327ae525f00f0b20471cc
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Sun Apr 24 17:12:01 2011 -0500

    Changed a transactionId in the Ice context to an operationId as a parameter for session router interfaces.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 199d796..d48be72 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -55,8 +55,19 @@ using namespace AsteriskSCF::SIP::V1;
 class RouteSessionCallback : public IceUtil::Shared
 {
 public:
-    RouteSessionCallback(pjsip_inv_session *inv_session, pjsip_tx_data *tdata)
-        : mInvSession(inv_session), mTData(tdata) { }
+    RouteSessionCallback(pjsip_inv_session *inv_session, 
+                         pjsip_tx_data *tdata,
+                         const SipSessionPtr& session,
+                         const std::string& destination,
+                         const std::string& operationId)
+        : mInvSession(inv_session), 
+          mTData(tdata),
+          mSession(session),
+          mDestination(destination),
+          mOperationId(operationId)
+    { 
+    }
+
     void callback(const Ice::AsyncResultPtr& r)
     {
         SessionRouterPrx router = SessionRouterPrx::uncheckedCast(r->getProxy());
@@ -78,14 +89,28 @@ public:
 private:
     pjsip_inv_session *mInvSession;
     pjsip_tx_data *mTData;
+    SipSessionPtr mSession;
+    std::string mDestination;
+    std::string mOperationId;
 };
 typedef IceUtil::Handle<RouteSessionCallback> RouteSessionCallbackPtr;
 
 class ConnectBridgedSessionsCallback : public IceUtil::Shared
 {
 public:
-    ConnectBridgedSessionsCallback(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, SipSessionPtr session)
-        : mInvSession(inv_session), mRData(rdata), mSession(session) { }
+    ConnectBridgedSessionsCallback(pjsip_inv_session *inv_session,
+                                   pjsip_rx_data *rdata, 
+                                   const SipSessionPtr& session,
+                                   const SipSessionPtr& otherSession,
+                                   const std::string& operationId)
+        : mInvSession(inv_session), 
+          mRData(rdata), 
+          mSession(session),
+          mOtherSession(otherSession),
+          mOperationId(operationId)
+
+    { 
+    }
 
     void callback(const Ice::AsyncResultPtr &r)
     {
@@ -110,6 +135,8 @@ private:
     pjsip_inv_session *mInvSession;
     pjsip_rx_data *mRData;
     SipSessionPtr mSession;
+    SipSessionPtr mOtherSession;
+    std::string mOperationId;
 };
 
 typedef IceUtil::Handle<ConnectBridgedSessionsCallback> ConnectBridgedSessionsCallbackPtr;
@@ -117,8 +144,18 @@ typedef IceUtil::Handle<ConnectBridgedSessionsCallback> ConnectBridgedSessionsCa
 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) { }
+    ConnectBridgedSessionsWithDestinationCallback(pjsip_inv_session *inv_session, 
+                                                 pjsip_rx_data *rdata, 
+                                                 SipSessionPtr session, 
+                                                 const std::string& target,
+                                                 const std::string& operationId)
+        : mInvSession(inv_session), 
+          mRData(rdata), 
+          mSession(session), 
+          mTarget(target),
+          mOperationId(operationId)
+    { 
+    }
 
     void callback(const Ice::AsyncResultPtr &r)
     {
@@ -151,6 +188,7 @@ private:
     pjsip_rx_data *mRData;
     SipSessionPtr mSession;
     std::string mTarget;
+    std::string mOperationId;
 };
 
 typedef IceUtil::Handle<ConnectBridgedSessionsWithDestinationCallback> ConnectBridgedSessionsWithDestinationCallbackPtr;
@@ -167,17 +205,6 @@ private:
     const std::string mCallbackName;
 };
 
-/**
- * Utility function to create an Ice context with a single entry. 
- * The entry in the context is a transaction id, and it is set to a UUID. 
- */
-Ice::Context nextTransactionalContext()
-{
-    Ice::Context context;
-    context[AsteriskSCF::SessionCommunications::V1::TransactionKey] = IceUtil::generateUUID();
-    return context;
-}
-
 typedef IceUtil::Handle<ListenerCallback> ListenerCallbackPtr;
 
 PJSipSessionModInfo::PJSipSessionModInfo(pjsip_inv_session *inv_session,
@@ -564,10 +591,10 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
         else
         {
             // If this is not an attended transfer we can just route the session as normally
-            RouteSessionCallbackPtr cb = new RouteSessionCallback(inv_session, tdata);
+            std::string operationId = ::IceUtil::generateUUID();
+            RouteSessionCallbackPtr cb = new RouteSessionCallback(inv_session, tdata, session, destination, operationId);
             Ice::CallbackPtr d = Ice::newCallback(cb, &RouteSessionCallback::callback);
-            Ice::Context context = nextTransactionalContext();
-            mSessionRouter->begin_routeSession(session->getSessionProxy(), destination, context, d);
+            mSessionRouter->begin_routeSession(operationId, session->getSessionProxy(), destination, d);
         }
     }
     catch (const Ice::CommunicatorDestroyedException &)
@@ -700,12 +727,12 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
 
         try
         {
-            ConnectBridgedSessionsCallbackPtr cb(new ConnectBridgedSessionsCallback(inv, rdata, session));
+            std::string operationId = ::IceUtil::generateUUID();
+            ConnectBridgedSessionsCallbackPtr cb(new ConnectBridgedSessionsCallback(inv, rdata, session, other_session, operationId));
             Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessions(). ";
-            Ice::Context context = nextTransactionalContext();
-            mSessionRouter->begin_connectBridgedSessions(session->getSessionProxy(), other_session->getSessionProxy(), context, d);
+            mSessionRouter->begin_connectBridgedSessions(operationId, session->getSessionProxy(), other_session->getSessionProxy(), d);
         }
         catch (const Ice::CommunicatorDestroyedException &)
         {
@@ -722,14 +749,15 @@ void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdat
         // Now that we have the target user we can pass this into routing and go on our marry way
         try
         {
+            std::string operationId = ::IceUtil::generateUUID();
             PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[mModule.id];
             SipSessionPtr session = session_mod_info->getSessionPtr();
-            ConnectBridgedSessionsWithDestinationCallbackPtr cb(new ConnectBridgedSessionsWithDestinationCallback(inv, rdata, session, target));
+            ConnectBridgedSessionsWithDestinationCallbackPtr cb(
+                    new ConnectBridgedSessionsWithDestinationCallback(inv, rdata, session, target, operationId));
             Ice::CallbackPtr d = Ice::newCallback(cb, &ConnectBridgedSessionsWithDestinationCallback::callback);
 
             lg(Debug) << "handleRefer() calling router connectBridgedSessionsWithDestination(). ";
-            Ice::Context context = nextTransactionalContext();
-            mSessionRouter->begin_connectBridgedSessionsWithDestination(session->getSessionProxy(), target, context, d);
+            mSessionRouter->begin_connectBridgedSessionsWithDestination(operationId, session->getSessionProxy(), target, d);
         }
         catch (const Ice::CommunicatorDestroyedException &)
         {

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list