[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
Tue Aug 24 08:46:31 CDT 2010


branch "master" has been updated
       via  11318dcd0ee197f7062f1495de173de1f52a19c6 (commit)
      from  79e0410bf6ed60383bee6c334b350fa40afde92e (commit)

Summary of changes:
 src/SipEndpoint.cpp        |   41 ++++++++++++++++++++++++++++++++++--
 src/SipEndpoint.h          |   48 ++++++++++++++++++++++++++++++-------------
 src/SipEndpointFactory.cpp |    8 ++++++-
 src/SipEndpointFactory.h   |    7 ++++++
 4 files changed, 85 insertions(+), 19 deletions(-)


- Log -----------------------------------------------------------------
commit 11318dcd0ee197f7062f1495de173de1f52a19c6
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 24 11:01:12 2010 -0300

    Add the ability to destroy an endpoint. While this isn't done yet (since it'll be done somewhere in signaling) everything that is needed to do it should exist.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index a1384a3..1c0cc53 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -11,6 +11,8 @@ namespace SipChannelService
 class SipSignalCommands : public Hydra::Session::V1::SignalCommands
 {
 public:
+	SipSignalCommands(SipEndpoint *endpoint) : mEndpoint(endpoint) { };
+
 	bool call(const Core::Endpoint::V1::EndpointIdPtr& caller, const Core::Endpoint::V1::EndpointIdPtr& destination, const Hydra::Session::V1::SignalCallbackPtr& callback, const Ice::Current&)
 	{
 		//stub
@@ -26,11 +28,19 @@ public:
 		//What's the difference between this and
 		//SignalCallback::terminated()?
 	}
+
+private:
+	/**
+	 * A pointer to the endpoint that created us.
+	 */
+	SipEndpoint* mEndpoint;
 };
 
 class SipSignalCallback : public Hydra::Session::V1::SignalCallback
 {
 public:
+	SipSignalCallback(SipEndpoint *endpoint) : mEndpoint(endpoint) { };
+
 	void ring(const Core::Endpoint::V1::EndpointIdPtr& ep, const Ice::Current&)
 	{
 		//stub
@@ -114,6 +124,12 @@ public:
 		//Similar to connected(), but the response code
 		//will be 183 instead of 200.
 	}
+
+private:
+	/**
+	 * A pointer to the endpoint that created us.
+	 */
+	SipEndpoint* mEndpoint;
 };
 
 class SipMediaSession : public Media::V1::Session
@@ -148,15 +164,34 @@ private:
 /**
  * Default constructor.
  */
-SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter)
+SipEndpoint::SipEndpoint(Ice::ObjectAdapterPtr adapter, boost::shared_ptr<SipEndpointFactory> factory) : mAdapter(adapter), mEndpointFactory(factory)
 {
-   mSignalCommands = new SipSignalCommands();
+   mSignalCommands = new SipSignalCommands(this);
    command = Hydra::Session::V1::SignalCommandsPrx::uncheckedCast(adapter->addWithUUID(mSignalCommands));
-   mSignalCallbacks = new SipSignalCallback();
+   mSignalCallbacks = new SipSignalCallback(this);
    callback = Hydra::Session::V1::SignalCallbackPrx::uncheckedCast(adapter->addWithUUID(mSignalCallbacks));
    mMediaSession = new SipMediaSession();
    mediaSession = Hydra::Media::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(mMediaSession));
 }
 
+/**
+ * Internal function called to destroy an endpoint. This is controlled by signaling.
+ */
+void SipEndpoint::destroy()
+{
+   // Remove all of the different interfaces we have exposed to the world.
+   mAdapter->remove(command->ice_getIdentity());
+   mSignalCommands = 0;
+   mAdapter->remove(callback->ice_getIdentity());
+   mSignalCallbacks = 0;
+   mAdapter->remove(mediaSession->ice_getIdentity());
+   mMediaSession = 0;
+
+   /* Now... remove ourselves from the factory, once this is done all of our references will be
+    * gone and we will cease to exist.
+    */
+   mEndpointFactory->remove(this);
+}
+
 }; // end SipChannelService
 }; // end Hydra
diff --git a/src/SipEndpoint.h b/src/SipEndpoint.h
index 96eb8b0..eb153bf 100644
--- a/src/SipEndpoint.h
+++ b/src/SipEndpoint.h
@@ -1,9 +1,14 @@
 #pragma once
 
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+
 #include <Core/Endpoint/EndpointIf.h>
 #include <Session/SessionIf.h>
 #include <Media/MediaIf.h>
 
+#include "SipEndpointFactory.h"
+
 namespace Hydra
 {
 
@@ -16,22 +21,35 @@ class SipSignalCallback;
 class SipEndpoint : public Hydra::Session::V1::SessionEndpoint
 {
 public:
-   SipEndpoint(Ice::ObjectAdapterPtr);
+   SipEndpoint(Ice::ObjectAdapterPtr, boost::shared_ptr<SipEndpointFactory>);
+
+   void destroy();
+
 private:
-	/**
-	 * An instance of signal commands.
-	 */
-	Hydra::Session::V1::SignalCommandsPtr mSignalCommands;
-
-	/**
-	 * An instance of signal callbacks.
-	 */
-	Hydra::Session::V1::SignalCallbackPtr mSignalCallbacks;
-
-	/**
-	 * An instance of a media session.
-	 */
-	Hydra::Media::V1::SessionPtr mMediaSession;
+   /**
+    * An instance of signal commands.
+    */
+   Hydra::Session::V1::SignalCommandsPtr mSignalCommands;
+
+   /**
+    * An instance of signal callbacks.
+    */
+   Hydra::Session::V1::SignalCallbackPtr mSignalCallbacks;
+
+   /**
+    * An instance of a media session.
+    */
+   Hydra::Media::V1::SessionPtr mMediaSession;
+
+   /**
+    * The Ice object adapter that our proxies were added to.
+    */
+   Ice::ObjectAdapterPtr mAdapter;
+
+   /**
+    * The endpoint factory that created us.
+    */
+   boost::shared_ptr<SipEndpointFactory> mEndpointFactory;
 };
 
 }; //End namespace SipChannelService
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index c019c4c..855823d 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -8,9 +8,15 @@ namespace SipChannelService
 
 Hydra::Session::V1::SessionEndpointPtr SipEndpointFactory::getEndpoint(std::string destination)
 {
-   Hydra::Session::V1::SessionEndpointPtr endpoint = new SipEndpoint(mAdapter);
+   Hydra::Session::V1::SessionEndpointPtr endpoint = new SipEndpoint(mAdapter, boost::shared_ptr<SipEndpointFactory>(this));
+   mEndpoints.push_back(endpoint);
    return endpoint;
 }
 
+void SipEndpointFactory::remove(Hydra::Session::V1::SessionEndpointPtr endpoint)
+{
+   mEndpoints.erase(std::remove(mEndpoints.begin(), mEndpoints.end(), endpoint), mEndpoints.end());
+}
+
 }; // end SipChannelService
 }; // end Hydra
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index 73cad9e..cad7eb9 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -19,11 +19,18 @@ public:
 SipEndpointFactory(Ice::ObjectAdapterPtr adapter) : mAdapter(adapter) { };
 
    Hydra::Session::V1::SessionEndpointPtr getEndpoint(std::string destination);
+
+   void remove(Hydra::Session::V1::SessionEndpointPtr);
 private:
    /**
     * A pointer to the object adapter that endpoints will be added to.
     */
    Ice::ObjectAdapterPtr mAdapter;
+
+   /**
+    * A vector of endpoints that this factory has created.
+    */
+   std::vector<Hydra::Session::V1::SessionEndpointPtr> mEndpoints;
 };
 
 }; // end SipChannelService

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list