[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Wed Oct 6 12:46:02 CDT 2010


branch "master" has been updated
       via  3a1fe7ff546ca1ed5fe5abb40f6058fbc28ad817 (commit)
      from  40a21c95e3e5b252ca2c4a41bc2636e2aacb4746 (commit)

Summary of changes:
 slice                     |    2 +-
 src/BridgeImpl.cpp        |   40 ++++++++++++++++++++++++++++++++++++++--
 src/BridgeImpl.h          |    7 ++++++-
 src/BridgeManagerImpl.cpp |   23 ++++++-----------------
 src/BridgeManagerImpl.h   |    5 +----
 src/Service.cpp           |    7 ++++---
 6 files changed, 56 insertions(+), 28 deletions(-)


- Log -----------------------------------------------------------------
commit 3a1fe7ff546ca1ed5fe5abb40f6058fbc28ad817
Author: Brent Eagles <beagles at digium.com>
Date:   Wed Oct 6 15:15:04 2010 -0230

    Add replaceSession method placeholder.
    Refactored construction a bit to make a little cleaner.

diff --git a/slice b/slice
index 0c62939..28254d6 160000
--- a/slice
+++ b/slice
@@ -1 +1 @@
-Subproject commit 0c629393e2f05dc0ed43bcc6305880949df36289
+Subproject commit 28254d693835ab4093fe46c55a2f1a85e53ef792
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index c6b6538..7fe4430 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -222,12 +222,14 @@ namespace BridgeService
 AsteriskSCF::BridgeService::BridgeImpl::BridgeImpl(
   const Ice::ObjectAdapterPtr& adapter,
   const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& ev,
-  const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr
+  const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+  const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& prx
   ) :
     mState(Running),
     mObjAdapter(adapter),
     mListeners(listenerMgr),
-    mSessionListener(new SessionListener(this))
+    mSessionListener(new SessionListener(this)),
+    mPrx(prx)
 {
     if(ev)
     {
@@ -432,6 +434,40 @@ void AsteriskSCF::BridgeService::BridgeImpl::removeListener(const AsteriskSCF::S
     mListeners->removeListener(listener);
 }
 
+void AsteriskSCF::BridgeService::BridgeImpl::replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& newSession, 
+  const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession, const Ice::Current&)
+{
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    statePreCheck();
+    std::vector<BridgeSession>::iterator i = find_if(mSessions.begin(), mSessions.end(), AsteriskSCF::BridgeService::FindImpl(oldSession));
+    if(i != mSessions.end())
+    {
+#if 0
+        i->session->removeBridge(mPrx, mSessionListenerPrx);
+        i->connector->unplug();
+        AsteriskSCF::SessionCommunications::V1::SessionInfoPtr info = newSession->addBridge(mPrx, mSessionListenerPrx);
+        i->session = newSession;
+        if(info->currentState == "ready")
+        {
+            i->connector = 0;
+        }
+        else
+        {
+            i->connector = mSplicer.connect(newSession);
+        }
+        AsteriskSCF::SessionCommunications::V1::SessionSeq sessions;
+        sessions.push_back(newSessions);
+        mListeners->sessionsAdded(sessions);
+        sessions.clear();
+        sessions.push_back(oldSession);
+        mListeners->sessionsRemoved(sessions);
+#endif
+        //
+        // TODO:Need to find a way to make this as exception safe as possible!
+        //
+    }
+}
+
 void AsteriskSCF::BridgeService::BridgeImpl::destroy(const Ice::Current& current)
 {
     {
diff --git a/src/BridgeImpl.h b/src/BridgeImpl.h
index 5122660..864ab62 100644
--- a/src/BridgeImpl.h
+++ b/src/BridgeImpl.h
@@ -38,7 +38,8 @@ namespace BridgeService
 
         BridgeImpl(const Ice::ObjectAdapterPtr& objAdapter,
                 const SessionCommunications::Bridging::V1::BridgeListenerPrx& ev,
-                const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr);
+                const AsteriskSCF::BridgeService::BridgeListenerMgrPtr& listenerMgr,
+                const AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx& prx);
 
         ~BridgeImpl();
 
@@ -55,6 +56,9 @@ namespace BridgeService
         void addListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& listener, const Ice::Current& current);
         void removeListener(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeListenerPrx& listener, const Ice::Current& current);
 
+        void replaceSession(const AsteriskSCF::SessionCommunications::V1::SessionPrx& newSession,
+          const AsteriskSCF::SessionCommunications::V1::SessionPrx& oldSession, const Ice::Current& current);
+
         //
         // Internal methods
         //
@@ -87,6 +91,7 @@ namespace BridgeService
         BridgeListenerMgrPtr mListeners;
         SessionCommunications::V1::SessionListenerPtr mSessionListener;
         SessionCommunications::V1::SessionListenerPrx mSessionListenerPrx;
+        AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx mPrx;
 
         void statePreCheck();
     };
diff --git a/src/BridgeManagerImpl.cpp b/src/BridgeManagerImpl.cpp
index 3b8e38e..5d1671b 100644
--- a/src/BridgeManagerImpl.cpp
+++ b/src/BridgeManagerImpl.cpp
@@ -56,27 +56,16 @@ namespace BridgeService
 
 AsteriskSCF::BridgeService::BridgeManagerImpl::BridgeManagerImpl(
     const Ice::ObjectAdapterPtr& adapter,
-    const std::string& name) :
+    const std::string& name,
+    const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx) :
     mName(name),
     mShuttingDown(false),
     mSuspended(false),
-    mAdapter(adapter)
+    mAdapter(adapter),
+    mSourceProxy(prx)
 {
     lg(Info) << "Created AsteriskSCF Session-Oriented Bridge Manager." ;
-}
-
-void AsteriskSCF::BridgeService::BridgeManagerImpl::setPublishProxy(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx)
-{
-    boost::unique_lock<boost::shared_mutex> lock(mLock);
-    mSourceProxy = prx;
-    if(!mListeners)
-    {
-        mListeners = new AsteriskSCF::BridgeService::BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
-    }
-    else
-    {
-        mListeners->setSource(mSourceProxy);
-    }
+    mListeners = new AsteriskSCF::BridgeService::BridgeManagerListenerMgr(mAdapter->getCommunicator(), mName, mSourceProxy);
 }
 
 AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeService::BridgeManagerImpl::createBridge(
@@ -105,7 +94,7 @@ AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx AsteriskSCF::BridgeS
         AsteriskSCF::SessionCommunications::Bridging::V1::BridgePrx::uncheckedCast(mAdapter->createProxy(id)));
     AsteriskSCF::BridgeService::BridgeListenerMgrPtr mgr(new BridgeListenerMgr(mAdapter->getCommunicator(), stringId, prx));
     
-    AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, listener, mgr);
+    AsteriskSCF::BridgeService::BridgeImplPtr bridge = new AsteriskSCF::BridgeService::BridgeImpl(mAdapter, listener, mgr, prx);
     Ice::ObjectPrx obj = mAdapter->add(bridge, id);
     
     lg(Info) << current.adapter->getCommunicator()->identityToString(current.id) << ": creating new bridge " << obj->ice_toString() << "." ;
diff --git a/src/BridgeManagerImpl.h b/src/BridgeManagerImpl.h
index ef2be04..5213532 100644
--- a/src/BridgeManagerImpl.h
+++ b/src/BridgeManagerImpl.h
@@ -23,11 +23,8 @@ namespace BridgeService
     {
     public:
         
-        BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name);
-
-        void setPublishProxy(const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx);
+        BridgeManagerImpl(const Ice::ObjectAdapterPtr& adapter, const std::string& name, const AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx& prx);
                 
-        
         //
         // AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManager Interface
         //
diff --git a/src/Service.cpp b/src/Service.cpp
index 9b28baf..e0899a8 100644
--- a/src/Service.cpp
+++ b/src/Service.cpp
@@ -65,11 +65,12 @@ void BridgingApp::start(const std::string& name, const Ice::CommunicatorPtr& com
     ConfiguredIceLoggerPtr iceLogger = createIceLogger(mAdapter);
     getLoggerFactory().setLogOutput(iceLogger->getLogger());
 
-    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr servant(new AsteriskSCF::BridgeService::BridgeManagerImpl(mAdapter, ManagerName));
+    Ice::Identity id = communicator->stringToIdentity(ManagerName);
     AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx s(
-        AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(mAdapter->add(servant, communicator->stringToIdentity(ManagerName))
-        )
+        AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPrx::uncheckedCast(mAdapter->createProxy(id))
     );
+    AsteriskSCF::SessionCommunications::Bridging::V1::BridgeManagerPtr servant(new AsteriskSCF::BridgeService::BridgeManagerImpl(mAdapter, ManagerName, s));
+    mAdapter->add(servant, id);
     mAdapter->activate();
 
     AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx management = 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list