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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Apr 21 11:45:20 CDT 2011


branch "master" has been updated
       via  665b6a29b567c13c6bbce45fab4ca422bf2e17aa (commit)
      from  99fbea34400b3eedcbee29014104cf60b332555a (commit)

Summary of changes:
 src/SessionListener.cpp   |  174 ++++++++++++++++++++-------------------------
 src/SessionOperations.cpp |    2 +-
 src/SessionWrapper.cpp    |   11 ++--
 3 files changed, 84 insertions(+), 103 deletions(-)


- Log -----------------------------------------------------------------
commit 665b6a29b567c13c6bbce45fab4ca422bf2e17aa
Author: Joshua Colp <jcolp at digium.com>
Date:   Thu Apr 21 13:35:25 2011 -0300

    Add support for indicate.

diff --git a/src/SessionListener.cpp b/src/SessionListener.cpp
index 2cf579f..b55ef67 100644
--- a/src/SessionListener.cpp
+++ b/src/SessionListener.cpp
@@ -42,105 +42,85 @@ public:
     {
     }
 
-    void connected(const SessionPrx& source, const Ice::Current&)
+    void indicated(const AsteriskSCF::SessionCommunications::V1::SessionPrx& source,
+        const AsteriskSCF::SessionCommunications::V1::IndicationPtr& indication, const Ice::Current& current)
     {
-        string proxyString = source->ice_toString();
-        mLogger(Debug) << FUNLOG << ": session connected " << proxyString;
-
-        try
-        {
-            SessionWrapperPtr session = mSessions->getSession(source);
-            if (!session)
-            {
-                mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
-                              << proxyString << " that does not match known sessions. Possible out of order operations.";
-                return;
-            }
-
-            session->setup();
+	AsteriskSCF::SessionCommunications::V1::ConnectedIndicationPtr connected;
+	AsteriskSCF::SessionCommunications::V1::RingingIndicationPtr ringing;
+	AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr stopped;
+
+	if ((connected = AsteriskSCF::SessionCommunications::V1::ConnectedIndicationPtr::dynamicCast(indication)))
+	{
+	    string proxyString = source->ice_toString();
+	    mLogger(Debug) << FUNLOG << ": session connected " << proxyString;
+
+	    try
+	    {
+		SessionWrapperPtr session = mSessions->getSession(source);
+		if (!session)
+		{
+		    mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
+				  << proxyString << " that does not match known sessions. Possible out of order operations.";
+		    return;
+		}
+
+		session->setup();
             
-            ConnectSessionOperation connector(source, mLogger);
-            mSessions->visitSessions(connector);
-        }
-        catch (const Ice::Exception& ex)
-        {
-            mLogger(Debug) << FUNLOG << ": " << ex.what();
-            throw;
-        }
-    }
-
-    void flashed(const SessionPrx& source, const Ice::Current&)
-    {
-        //
-        // TODO: Is there something to be done here?
-        // 
-    }
-
-    void held(const SessionPrx& source, const Ice::Current&)
-    {
-        //
-        // TODO: Should this affect the media operations.
-        // 
-    }
-
-    void progressing(const SessionPrx& source, 
-      const ResponseCodePtr& response, const Ice::Current&)
-    {
-        //
-        // TODO: Is there something to be done here?
-        // 
-    }
-
-    void ringing(const SessionPrx& source, const Ice::Current&)
-    {
-        //
-        // TODO: Who gets the ring notifications will likely depend on configuration, etc.
-        //
-        RingSessionOperation ringer(source, mLogger);
-        mSessions->visitSessions(ringer);
-    }
-
-    void stopped(const SessionPrx& source, const ResponseCodePtr& response, const Ice::Current& current)
-    {
-        string proxyString = source->ice_toString();
-        mLogger(Debug) << FUNLOG << ": session stopped " << proxyString;
-
-        //
-        // IMPLNOTE: The AMI approach.
-        // Stack some operations in a callback. In this case it will be:
-        // 1. getSession()
-        // 2. removeBridge()
-        // 3. disconnect() or destroy()
-        //
-        // The latter two should be coupled as a transaction. One way to go about this would be to replicate the
-        // operations that need to be done together and checkpoint after each one completes. Actually, there are lots of
-        // ways to go about it. Need to think on this more.
-        //
-        // Q. What is the proper order of operations here, should removeBridge be called before or after we
-        // "disconnect" the session? 
-        //
-        SessionWrapperPtr session;
-        session = mSessions->getSession(source);
-        if (!session)
-        {
-            mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
-                          << proxyString << " that does not match known sessions. Possible out of order operations.";
-            return;
-        }
-
-        //
-        // We don't actually have the proxy for this object, but we can create one on the fly.
-        //
-        SessionListenerPrx listenerPrx = SessionListenerPrx::uncheckedCast(current.adapter->createProxy(current.id));
-
-        //
-        // Shutdown is handled asynchronously, so there won't be any exceptions that need to be caught here.
-        //
-        session->shutdown(listenerPrx, new ResponseCode);
-    }
-
-    void unheld(const SessionPrx& source, const Ice::Current&)
-    {
+		ConnectSessionOperation connector(source, mLogger);
+		mSessions->visitSessions(connector);
+	    }
+	    catch (const Ice::Exception& ex)
+	    {
+		mLogger(Debug) << FUNLOG << ": " << ex.what();
+		throw;
+	    }
+	}
+	else if ((ringing = AsteriskSCF::SessionCommunications::V1::RingingIndicationPtr::dynamicCast(indication)))
+	{
+	    //
+	    // TODO: Who gets the ring notifications will likely depend on configuration, etc.
+	    //
+	    RingSessionOperation ringer(source, mLogger);
+	    mSessions->visitSessions(ringer);
+	}
+	else if ((stopped = AsteriskSCF::SessionCommunications::V1::StoppedIndicationPtr::dynamicCast(indication)))
+	{
+	    string proxyString = source->ice_toString();
+	    mLogger(Debug) << FUNLOG << ": session stopped " << proxyString;
+
+	    //
+	    // IMPLNOTE: The AMI approach.
+	    // Stack some operations in a callback. In this case it will be:
+	    // 1. getSession()
+	    // 2. removeBridge()
+	    // 3. disconnect() or destroy()
+	    //
+	    // The latter two should be coupled as a transaction. One way to go about this would be to replicate the
+	    // operations that need to be done together and checkpoint after each one completes. Actually, there are lots of
+	    // ways to go about it. Need to think on this more.
+	    //
+	    // Q. What is the proper order of operations here, should removeBridge be called before or after we
+	    // "disconnect" the session? 
+	    //
+	    SessionWrapperPtr session;
+	    session = mSessions->getSession(source);
+	    if (!session)
+	    {
+		mLogger(Info) << "Attempt to respond to connected notification for session with proxy "
+			      << proxyString << " that does not match known sessions. Possible out of order operations.";
+		return;
+	    }
+
+	    //
+	    // We don't actually have the proxy for this object, but we can create one on the fly.
+	    //
+	    SessionListenerPrx listenerPrx = SessionListenerPrx::uncheckedCast(current.adapter->createProxy(current.id));
+	    
+	    //
+	    // Shutdown is handled asynchronously, so there won't be any exceptions that need to be caught here.
+	    //
+	    session->shutdown(listenerPrx, new ResponseCode);
+	}
     }
 
 private:
diff --git a/src/SessionOperations.cpp b/src/SessionOperations.cpp
index 0e982aa..56a5c5a 100644
--- a/src/SessionOperations.cpp
+++ b/src/SessionOperations.cpp
@@ -70,7 +70,7 @@ void RingSessionOperation::operator()(const SessionWrapperPtr& session)
             //
             // TODO: AMI.. or would this be better as a oneway. Do we care if we get a response etc?
             //
-            s->ring();
+	    s->indicate(new AsteriskSCF::SessionCommunications::V1::RingIndication());
         }
         catch (const Ice::ObjectNotExistException& ex)
         {
diff --git a/src/SessionWrapper.cpp b/src/SessionWrapper.cpp
index a13dd18..a4da471 100644
--- a/src/SessionWrapper.cpp
+++ b/src/SessionWrapper.cpp
@@ -343,10 +343,11 @@ void SessionWrapper::connect()
         // care of dealing with the AMI callbacks. More accurately, there is a class wide singleton for the callback
         // object and the SessionWrapper itself is passed as the cookie. No further "book-keeping" is required.
         //
-        mSession->session->begin_connect(
-            newCallback_Session_connect(new ConnectRequestCallback(this, mLogger),
-                    &ConnectRequestCallback::connectCB,
-                    &ConnectRequestCallback::failureCB));
+        mSession->session->begin_indicate(
+	    new AsteriskSCF::SessionCommunications::V1::ConnectIndication(),
+            newCallback_Session_indicate(new ConnectRequestCallback(this, mLogger),
+		&ConnectRequestCallback::connectCB,
+		&ConnectRequestCallback::failureCB));
     }
 }
 
@@ -359,7 +360,7 @@ void SessionWrapper::ring()
             return;
         }
     }
-    tryOneWay(mSession->session)->ring();
+    tryOneWay(mSession->session)->indicate(new AsteriskSCF::SessionCommunications::V1::RingIndication());
 }
 
 bool SessionWrapper::setConnected()

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


-- 
asterisk-scf/release/bridging.git



More information about the asterisk-scf-commits mailing list