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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Sep 23 17:10:33 CDT 2010


branch "master" has been updated
       via  d90268b1e77a622f1b2701081393741369c9f5fc (commit)
      from  b44edb278caaf91626aadbdb850cdaab21cd8e93 (commit)

Summary of changes:
 local-slice/SipStateReplicationIf.ice |   14 ++--
 src/CMakeLists.txt                    |    8 ++-
 src/PJSipSessionModule.cpp            |   16 ++--
 src/SipStateReplicator.cpp            |  127 ---------------------------------
 src/SipStateReplicator.h              |    9 ++-
 src/SipStateReplicatorApp.cpp         |    2 +-
 src/SipStateReplicatorListener.cpp    |    4 +-
 7 files changed, 31 insertions(+), 149 deletions(-)
 delete mode 100644 src/SipStateReplicator.cpp


- Log -----------------------------------------------------------------
commit d90268b1e77a622f1b2701081393741369c9f5fc
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Sep 23 17:10:59 2010 -0500

    Use the templated state replicator instead of rolling our own. So nice.

diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index be1874e..baf856b 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -22,7 +22,7 @@ module V1
 
    class SipStateItem
    {
-      string mId;
+      string key;
       string mSessionId;
    };
 
@@ -30,18 +30,18 @@ module V1
 
    interface SipStateReplicatorListener
    {
-      void removeStateNotice(Ice::StringSeq itemKeys);
-	  void setStateNotice(SipStateItemSeq items);
+      void stateRemoved(Ice::StringSeq itemKeys);
+	  void stateSet(SipStateItemSeq items);
    };
 
    interface SipStateReplicator
    {
       void addListener(SipStateReplicatorListener *listener);
-	  idempotent void removeListener(SipStateReplicatorListener *listener);
+	  void removeListener(SipStateReplicatorListener *listener);
 	  void setState (SipStateItemSeq items);
-	  idempotent void removeState(SipStateItemSeq items);
-	  SipStateItemSeq getState(Ice::StringSeq itemKeys);
-	  SipStateItemSeq getAllStates();
+	  void removeState(Ice::StringSeq items);
+	  idempotent SipStateItemSeq getState(Ice::StringSeq itemKeys);
+	  idempotent SipStateItemSeq getAllState();
    };
    class SipDialogStateItem extends SipStateItem
    {
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f8aadd3..0938b12 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -55,9 +55,15 @@ hydra_component_add_slice(SipStateReplicator SipStateReplicationIf)
 hydra_component_add_slice(SipStateReplicator RoutingIf)
 hydra_component_add_slice(SipStateReplicator MediaRTPIf)
 
+#This line allows us to use the templated state replicator
+#code from the SIP component. This statement is not the most
+#permanent of changes and assumes the directories are
+#structured in the way that gitall structures them.
+include_directories(../../statereplicator/src)
+
 hydra_component_add_file(SipStateReplicator SipStateReplicatorApp.cpp)
 hydra_component_add_file(SipStateReplicator SipStateReplicator.h)
-hydra_component_add_file(SipStateReplicator SipStateReplicator.cpp)
+#hydra_component_add_file(SipStateReplicator SipStateReplicator.cpp)
 
 hydra_component_add_ice_libraries(SipStateReplicator IceStorm)
 
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 89fc19b..b43be02 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -52,8 +52,8 @@ public:
    PJSipDialogModInfo(pjsip_dialog *dialog) : mDialogState(new SipDialogStateItem) , mNeedsReplication(true)
    {
       //XXX Is there a way to tell ICE to make the default
-	  //constructor for SipStateItem set mId?
-      mDialogState->mId = IceUtil::generateUUID();
+	  //constructor for SipStateItem set key?
+      mDialogState->key = IceUtil::generateUUID();
 	  updateDialogState(dialog);
    }
    ~PJSipDialogModInfo()
@@ -131,7 +131,7 @@ class PJSipTransactionModInfo
 public:
    PJSipTransactionModInfo(pjsip_transaction *transaction) : mTransactionState(new SipTransactionStateItem), mNeedsReplication(true)
    {
-      mTransactionState->mId = IceUtil::generateUUID();
+      mTransactionState->key = IceUtil::generateUUID();
 	  updateTransactionState(transaction);
    }
    ~PJSipTransactionModInfo()
@@ -192,7 +192,7 @@ class PJSipSessionModInfo
 public:
    PJSipSessionModInfo(pjsip_inv_session *inv_session) : mSessionState(new SipSessionStateItem), mNeedsReplication(true)
    {
-      mSessionState->mId = IceUtil::generateUUID();
+      mSessionState->key = IceUtil::generateUUID();
    }
    ~PJSipSessionModInfo()
    {
@@ -234,12 +234,12 @@ static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo
 		PJSipSessionModInfo *sessionInfo)
 {
 	SipStateItemSeq setItems;
-	SipStateItemSeq removeItems;
+	Ice::StringSeq removeItems;
 	if (dlgInfo)
 	{
 		if (dlgInfo->mNeedsRemoval == true)
 		{
-			removeItems.push_back(dlgInfo->mDialogState);
+			removeItems.push_back(dlgInfo->mDialogState->key);
 		}
 		else if (dlgInfo->mNeedsReplication == true)
 		{
@@ -251,7 +251,7 @@ static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo
 	{
 		if (tsxInfo->mNeedsRemoval == true)
 		{
-			removeItems.push_back(tsxInfo->mTransactionState);
+			removeItems.push_back(tsxInfo->mTransactionState->key);
 		}
 		else if (tsxInfo->mNeedsReplication == true)
 		{
@@ -263,7 +263,7 @@ static void replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo
 	{
 		if (sessionInfo->mNeedsRemoval == true)
 		{
-			removeItems.push_back(sessionInfo->mSessionState);
+			removeItems.push_back(sessionInfo->mSessionState->key);
 		}
 		else if (sessionInfo->mNeedsReplication == true)
 		{
diff --git a/src/SipStateReplicator.cpp b/src/SipStateReplicator.cpp
deleted file mode 100644
index f4b14fe..0000000
--- a/src/SipStateReplicator.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Asterisk Scalable Communications Framework
- *
- * Copyright (C) 2010 -- Digium, Inc.
- *
- * All rights reserved.
- */
-
-#include <IceUtil/UUID.h>
-
-#include <boost/thread.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include "SipStateReplicator.h"
-
-namespace AsteriskSCF
-{
-namespace SipChannelService
-{
-
-using namespace AsteriskSCF::SIP::V1;
-
-struct SipStateReplicatorImpl
-{
-public:
-   SipStateReplicatorImpl(std::string name) : mName(name) {}
-   void addListenerImpl(SipStateReplicatorListenerPrx listener)
-   {
-      mListeners.push_back(listener);
-   }
-   void removeListenerImpl(SipStateReplicatorListenerPrx listener)
-   {
-      mListeners.erase(std::find(mListeners.begin(), mListeners.end(), listener));
-   }
-   void setStateImpl(SipStateItemSeq items)
-   {
-      for (SipStateItemSeq::iterator iter = items.begin();
-            iter != items.end(); ++iter)
-      {
-         //Here, we try to find the item in mStateItems so 
-         //that we can update it if necessary. If we don't
-         //find it, we just push the new item onto mStateItems.
-
-		 //Then after we update our local stuff, we need to
-         //iterate over mListeners and call setStateNotice
-         //for each of the listeners.
-      }
-   }
-   void removeStateImpl(SipStateItemSeq items)
-   {
-      Ice::StringSeq removalKeys;
-      for (SipStateItemSeq::iterator iter = items.begin();
-            iter != items.end(); ++iter)
-      {
-	     mStateItems.erase(iter);
-		 removalKeys.push_back((*iter)->mId);
-      }
-      for (std::vector<SipStateReplicatorListenerPrx>::iterator listenerIter = mListeners.begin();
-               listenerIter != mListeners.end(); ++listenerIter)
-      {
-         (*listenerIter)->removeStateNotice(removalKeys);
-      }
-   }
-
-   SipStateItemSeq getStateImpl(Ice::StringSeq itemKeys)
-   {
-      SipStateItemSeq returnItems;
-	  //XXX Once I have the SipStateItem class set up,
-	  //this'll be a simple call to std::set_intersection
-	  //to get the items to return.
-	  return returnItems;
-   }
-
-   SipStateItemSeq getAllStatesImpl()
-   {
-      return mStateItems;
-   }
-
-   std::vector<SipStateReplicatorListenerPrx> mListeners;
-   SipStateItemSeq mStateItems;
-   std::string mName;
-};
-
-SipStateReplicatorI::SipStateReplicatorI(std::string name) : mImpl(new SipStateReplicatorImpl(name)) {}
-
-SipStateReplicatorI::~SipStateReplicatorI()
-{
-   delete mImpl;
-}
-
-void SipStateReplicatorI::addListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current &)
-{
-   mImpl->addListenerImpl(listener);
-}
-
-void SipStateReplicatorI::removeListener(const SipStateReplicatorListenerPrx &listener, const Ice::Current &)
-{
-   mImpl->removeListenerImpl(listener);
-}
-
-void SipStateReplicatorI::setState(const SipStateItemSeq &items, const Ice::Current &)
-{
-   mImpl->setStateImpl(items);
-}
-
-void SipStateReplicatorI::removeState(const SipStateItemSeq &items, const Ice::Current &)
-{
-   mImpl->removeStateImpl(items);
-}
-
-SipStateItemSeq SipStateReplicatorI::getState(const Ice::StringSeq &itemKeys, const Ice::Current &)
-{
-   return mImpl->getStateImpl(itemKeys);
-}
-
-SipStateItemSeq SipStateReplicatorI::getAllStates(const Ice::Current &)
-{
-   return mImpl->getAllStatesImpl();
-}
-
-std::string SipStateReplicatorI::getName()
-{
-   return mImpl->mName;
-}
-
-};
-};
diff --git a/src/SipStateReplicator.h b/src/SipStateReplicator.h
index 194c995..1d707a1 100644
--- a/src/SipStateReplicator.h
+++ b/src/SipStateReplicator.h
@@ -10,13 +10,14 @@
 
 #include <Ice/Ice.h>
 #include "SipStateReplicationIf.h"
+#include "StateReplicator.h"
 
 namespace AsteriskSCF
 {
 namespace SipChannelService
 {
-
 using namespace AsteriskSCF::SIP::V1;
+#if 0
 class SipStateReplicatorI : public SipStateReplicator
 {
 public:
@@ -33,7 +34,9 @@ private:
    struct SipStateReplicatorImpl *mImpl;
    //SipStateReplicatorImpl *mImpl;
 };
+#endif
 
+typedef AsteriskSCF::StateReplication::StateReplicator<SipStateReplicator, SipStateItemPtr, std::string, SipStateReplicatorListenerPrx> SipStateReplicatorI;
 typedef IceUtil::Handle<SipStateReplicatorI> SipStateReplicatorIPtr;
 
 class SipStateReplicatorListenerI : public SipStateReplicatorListener
@@ -41,8 +44,8 @@ class SipStateReplicatorListenerI : public SipStateReplicatorListener
 public:
    SipStateReplicatorListenerI();
    ~SipStateReplicatorListenerI();
-   void removeStateNotice(const Ice::StringSeq&, const Ice::Current&);
-   void setStateNotice(const SipStateItemSeq&, const Ice::Current&);
+   void stateRemoved(const Ice::StringSeq&, const Ice::Current&);
+   void stateSet(const SipStateItemSeq&, const Ice::Current&);
    bool operator==(SipStateReplicatorListenerI &rhs);
 private:
    struct SipStateReplicatorListenerImpl *mImpl;
diff --git a/src/SipStateReplicatorApp.cpp b/src/SipStateReplicatorApp.cpp
index 6797a3e..0224430 100644
--- a/src/SipStateReplicatorApp.cpp
+++ b/src/SipStateReplicatorApp.cpp
@@ -188,7 +188,7 @@ void SipStateReplicatorApp::initialize(const std::string appName)
    // Create and publish our ComponentService interface support.
    mComponentService = new ComponentServiceImpl(*this);
    mAdapter->add(mComponentService, communicator()->stringToIdentity(ComponentServiceId));
-   mStateReplicator = new SipStateReplicatorI(communicator()->getProperties()->getPropertyWithDefault("SipStateReplicator.Name", "default"));
+   mStateReplicator = new SipStateReplicatorI();
    mAdapter->add(mStateReplicator, communicator()->stringToIdentity(ServiceDiscoveryId));
 
    mAdapter->activate();
diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index c727738..2570926 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -237,12 +237,12 @@ SipStateReplicatorListenerI::~SipStateReplicatorListenerI()
    delete mImpl;
 }
 
-void SipStateReplicatorListenerI::removeStateNotice(const Ice::StringSeq& itemKeys, const Ice::Current&)
+void SipStateReplicatorListenerI::stateRemoved(const Ice::StringSeq& itemKeys, const Ice::Current&)
 {
    mImpl->removeStateNoticeImpl(itemKeys);
 }
 
-void SipStateReplicatorListenerI::setStateNotice(const SipStateItemSeq& items, const Ice::Current&)
+void SipStateReplicatorListenerI::stateSet(const SipStateItemSeq& items, const Ice::Current&)
 {
    mImpl->setStateNoticeImpl(items);
 }

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list