[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
Thu Aug 26 09:41:42 CDT 2010
branch "master" has been updated
via 744ae259211f313c3676a39f943226efb456eae1 (commit)
from 4d0a948da331e1c497c5f2332363476509e86ba4 (commit)
Summary of changes:
src/BridgeImpl.cpp | 93 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 61 insertions(+), 32 deletions(-)
- Log -----------------------------------------------------------------
commit 744ae259211f313c3676a39f943226efb456eae1
Author: Brent Eagles <beagles at digium.com>
Date: Thu Aug 26 12:09:44 2010 -0230
Implement some of the broadcasting methods using templates to ease on the boilerplate code.
Added a connected() callback forward to the admin endpoint.
diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index 04e10b1..b734089 100644
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -118,43 +118,28 @@ namespace BridgeService
};
//
- // Functor to support broadcasting ringing notifications.
- //
- // TODO: Replace call with AMI invocation and callback.
+ // Functor to support broadcasting busy notifications.
//
- class RingingBroadcaster : public std::unary_function<BridgeImpl::BridgeEndpoint, void>
+ struct BusyImpl : public std::binary_function<Hydra::Core::Endpoint::V1::EndpointIdPtr, Hydra::Session::V1::SignalCallbackPrx, void>
{
- public:
- RingingBroadcaster(const Core::Endpoint::V1::EndpointIdPtr& id) :
- mId(id)
- {
+ void operator()(const Hydra::Core::Endpoint::V1::EndpointIdPtr source, const Hydra::Session::V1::SignalCallbackPrx& p)
+ {
+ p->busy(source);
}
+ };
- void operator()(const BridgeImpl::BridgeEndpoint& b)
+ struct RingImpl : public std::binary_function<Hydra::Core::Endpoint::V1::EndpointIdPtr, Hydra::Session::V1::SignalCallbackPrx, void>
+ {
+ void operator()(const Hydra::Core::Endpoint::V1::EndpointIdPtr source, const Hydra::Session::V1::SignalCallbackPrx& p)
{
- if(b.endpoint)
- {
- Hydra::Session::V1::SessionEndpointPtr p(Hydra::Session::V1::SessionEndpointPtr::dynamicCast(b.endpoint));
- assert(p != 0);
- if(p->callback)
- {
- p->callback->ring(mId);
- }
- }
+ p->ring(source);
}
- private:
- Core::Endpoint::V1::EndpointIdPtr mId;
};
- //
- // Functor to support broadcasting busy notifications.
- //
- // TODO: Replace call with AMI invocation and callback.
- //
- class BusyBroadcaster : public std::unary_function<BridgeImpl::BridgeEndpoint, void>
+ class BroadcasterBase : public std::unary_function<BridgeImpl::BridgeEndpoint, void>
{
public:
- BusyBroadcaster(const Core::Endpoint::V1::EndpointIdPtr& id) :
+ BroadcasterBase(const Core::Endpoint::V1::EndpointIdPtr& id) :
mId(id)
{
}
@@ -167,12 +152,52 @@ namespace BridgeService
assert(p != 0);
if(p->callback)
{
- p->callback->busy(mId);
+ doOp(p->callback);
}
}
+
}
- private:
+ protected:
Core::Endpoint::V1::EndpointIdPtr mId;
+
+ virtual void doOp(const Hydra::Session::V1::SignalCallbackPrx& p)
+ {
+ }
+ };
+
+ template <class F>
+ class Broadcaster : public BroadcasterBase
+ {
+ public:
+ Broadcaster(const Core::Endpoint::V1::EndpointIdPtr& id) :
+ BroadcasterBase(id)
+ {
+ }
+ protected:
+ void doOp(const Hydra::Session::V1::SignalCallbackPrx& p)
+ {
+ F f;
+ f(mId, p);
+ }
+ };
+
+ template <class F>
+ class BroadcasterWithResponseCode : public BroadcasterBase
+ {
+ public:
+ BroadcasterWithResponseCode(const Core::Endpoint::V1::EndpointIdPtr& id, const Session::V1::ResponseCodePtr& responseCode) :
+ BroadcasterBase(id),
+ mResponseCode(responseCode)
+ {
+ }
+
+ protected:
+ Session::V1::ResponseCodePtr mResponseCode;
+ void doOp(const Hydra::Session::V1::SignalCallbackPrx& p)
+ {
+ F f;
+ f(mId, p, mResponseCode);
+ }
};
class DefaultBridgeSignallingCallback : public Session::V1::SignalCallback
@@ -505,6 +530,10 @@ void Hydra::BridgeService::BridgeImpl::endpointConnected(const Hydra::Core::Endp
mEndpoints.push_back(BridgeEndpoint(i->second, mSplicer.connect(endpointIdToString(id), i->second->mediaSession)));
mQueuedEndpoints.erase(i);
}
+ if(mAdminEndpoint.get() != 0 && mAdminEndpoint->endpoint && mAdminEndpoint->endpoint->callback)
+ {
+ mAdminEndpoint->endpoint->callback->connected(id);
+ }
}
void Hydra::BridgeService::BridgeImpl::endpointTerminated(const Hydra::Core::Endpoint::V1::EndpointIdPtr& id,
@@ -525,7 +554,7 @@ void Hydra::BridgeService::BridgeImpl::endpointTerminated(const Hydra::Core::End
{
removeEndpoint(id, current);
}
- catch(Hydra::System::Component::V1::ShuttingDown&)
+ catch(const Hydra::System::Component::V1::ShuttingDown&)
{
}
catch(const Ice::ObjectNotExistException&)
@@ -559,7 +588,7 @@ void Hydra::BridgeService::BridgeImpl::endpointRinging(const Hydra::Core::Endpoi
}
else
{
- std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::RingingBroadcaster(id));
+ std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::Broadcaster<Hydra::BridgeService::RingImpl>(id));
}
}
@@ -573,7 +602,7 @@ void Hydra::BridgeService::BridgeImpl::endpointBusy(const Hydra::Core::Endpoint:
}
else
{
- std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::BusyBroadcaster(id));
+ std::for_each(mEndpoints.begin(), mEndpoints.end(), Hydra::BridgeService::Broadcaster<Hydra::BridgeService::BusyImpl>(id));
}
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/bridging.git
More information about the asterisk-scf-commits
mailing list