[asterisk-scf-commits] asterisk-scf/examples.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Jun 24 11:38:54 CDT 2011
branch "master" has been updated
via f3ce0396326a3030015ca574f355f4e4bf4d4a93 (commit)
via 4e2c7254f769ad6ad89f82de10b9fb4754684653 (commit)
from 6baae00265c8b26c8d6b51b60a21f8cc06390741 (commit)
Summary of changes:
Bridge_SessionListener.py | 48 +++++++++++++++++++++++++++++---------------
README.txt | 10 +++++++++
2 files changed, 41 insertions(+), 17 deletions(-)
create mode 100644 README.txt
- Log -----------------------------------------------------------------
commit f3ce0396326a3030015ca574f355f4e4bf4d4a93
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Jun 24 11:38:41 2011 -0500
Add some more messages at start-up.
diff --git a/Bridge_SessionListener.py b/Bridge_SessionListener.py
index 6dc890d..def0b16 100755
--- a/Bridge_SessionListener.py
+++ b/Bridge_SessionListener.py
@@ -65,9 +65,9 @@ class BridgeListener(AsteriskSCF.SessionCommunications.V1.BridgeListener):
for s in sessions:
try:
s.addListener(AsteriskSCF.SessionCommunications.V1.SessionListenerPrx.uncheckedCast(self.adapter.createDirectProxy(self.adapter.getCommunicator().stringToIdentity(SessionListenerID))))
- print "Added ourselves as a listener to session %s with endpoint %s" % (s.ice_getIdentity().name, s.getEndpoint().getId())
+ print "Added ourself as a listener to session %s with endpoint %s" % (s.ice_getIdentity().name, s.getEndpoint().getId())
except Ice.Exception as ex:
- print "Exception caught while attempting to add ourselves as a SessionListener: " + ex.what()
+ print "Exception caught while attempting to add ourself as a SessionListener: " + ex.what()
def sessionsRemoved(self, sessionBridge, sessions, current = None):
print "Sessions removed from bridge %s" % (sessionBridge.ice_getIdentity().name)
def stopped(self, sessionBridge, current = None):
@@ -90,18 +90,26 @@ class BridgeManagerListener(AsteriskSCF.SessionCommunications.V1.BridgeManagerLi
class ListenerApp(Ice.Application):
def run(self, args):
+
+ print "Starting " + sys.argv[0]
# First thing we're going to do is create an object adapter.
adapter = self.communicator().createObjectAdapterWithEndpoints("ExampleListener", "default")
# Now we add instances of our listeners to the object adapter. This will allow
- # us to create proxies to the objects when we want to add ourselves as a listener
+ # us to create proxies to the objects when we want to add ourself as a listener
# to sessions, bridges, etc.
adapter.add(BridgeManagerListener(adapter), self.communicator().stringToIdentity(BridgeManagerListenerID))
+ print "Added BridgeManagerListener to our object adapter"
+
adapter.add(BridgeListener(adapter), self.communicator().stringToIdentity(BridgeListenerID))
+ print "Added BridgeListener to our object adapter"
+
adapter.add(SessionListener(adapter), self.communicator().stringToIdentity(SessionListenerID))
+ print "Added SessionListener to our object adapter"
adapter.activate()
+ print "Activated our object adapter"
# Now we need to find the bridge manager. We use the service locator for this.
# First, we get a proxy to the service locator.
@@ -123,22 +131,28 @@ class ListenerApp(Ice.Application):
print "Exception while attempting to locate BridgeManager: " + ex.what()
self.bridgeManager = AsteriskSCF.SessionCommunications.V1.BridgeManagerPrx.checkedCast(service)
- # We add ourselves as a listener to the bridge manager.
- self.BridgeManagerListenerPrx = AsteriskSCF.SessionCommunications.V1.BridgeManagerListenerPrx.uncheckedCast(adapter.createDirectProxy(self.communicator().stringToIdentity(BridgeManagerListenerID)))
+ print "Acquired proxy to the BridgeManager"
+
+ # We add ourself as a listener to the bridge manager.
+ self.bridgeManagerListenerPrx = AsteriskSCF.SessionCommunications.V1.BridgeManagerListenerPrx.uncheckedCast(adapter.createDirectProxy(self.communicator().stringToIdentity(BridgeManagerListenerID)))
try:
- self.bridgeManager.addListener(self.BridgeManagerListenerPrx)
+ self.bridgeManager.addListener(self.bridgeManagerListenerPrx)
except Ice.Exception as ex:
- print "Exception while attempting to add ourselves as a BridgeManagerListener: " + ex.what()
+ print "Exception while attempting to add ourself as a BridgeManagerListener: " + ex.what()
+
+ print "Added ourself as a BridgeManagerListener"
- # We also add ourselves as a default bridge listener. This means that we will automatically
- # have ourselves added as a listener to any bridge that gets created.
- self.BridgeListenerPrx = AsteriskSCF.SessionCommunications.V1.BridgeListenerPrx.uncheckedCast(adapter.createDirectProxy(self.communicator().stringToIdentity(BridgeListenerID)))
+ # We also add ourself as a default bridge listener. This means that we will automatically
+ # have ourself added as a listener to any bridge that gets created.
+ self.bridgeListenerPrx = AsteriskSCF.SessionCommunications.V1.BridgeListenerPrx.uncheckedCast(adapter.createDirectProxy(self.communicator().stringToIdentity(BridgeListenerID)))
try:
- self.bridgeManager.addDefaultBridgeListener(self.BridgeListenerPrx)
+ self.bridgeManager.addDefaultBridgeListener(self.bridgeListenerPrx)
except Ice.Exception as ex:
- print "Exception while attempting to add ourselves as a DefaultBridgeListener: " + ex.what()
+ print "Exception while attempting to add ourself as a DefaultBridgeListener: " + ex.what()
+
+ print "Added ourself as a default BridgeListener"
- # We want to remove ourselves as listeners when we terminate, so we need to hook into the
+ # We want to remove ourself as listeners when we terminate, so we need to hook into the
# termination signal. Ice.Application provides a nice way to do this.
self.callbackOnInterrupt()
# And now we wait...
@@ -152,15 +166,15 @@ class ListenerApp(Ice.Application):
def interruptCallback(self, sig):
print "Removing ourself as a default bridge listener"
try:
- self.bridgeManager.removeDefaultBridgeListener(self.BridgeListenerPrx)
+ self.bridgeManager.removeDefaultBridgeListener(self.bridgeListenerPrx)
except Ice.Exception as ex:
- print "Error trying to remove ourselves as a default bridge listener: " + ex.what()
+ print "Error trying to remove ourself as a default bridge listener: " + ex.what()
print "Removing ourself as a bridge manager listener"
try:
- self.bridgeManager.removeListener(self.BridgeManagerListenerPrx)
+ self.bridgeManager.removeListener(self.bridgeManagerListenerPrx)
except Ice.Exception as ex:
- print "Error tryint to remove ourselves as a bridge manager listener: " + ex.what()
+ print "Error tryint to remove ourself as a bridge manager listener: " + ex.what()
Ice.Application._destroyOnInterruptCallback(sig)
commit 4e2c7254f769ad6ad89f82de10b9fb4754684653
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Jun 24 11:29:55 2011 -0500
Add a README.txt file to explain the contents of the repo.
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..2dd8675
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,10 @@
+This repo provides code samples to illustrate how Asterisk SCF's APIs and extension
+points can be used. Below are descriptions of the samples included in the repo.
+
+* Bridge_SessionListener.py
+
+This script creates a BridgeListener, BridgeManagerListener, and a SessionListener.
+At startup, it adds itself as a BridgeManagerListener and a default BridgeListener.
+When sessions are added to a bridge, it then adds itself as a SessionListener. All
+events on bridges and sessions are caught by this script. The script simply prints
+a message to stdout when an event is received.
-----------------------------------------------------------------------
--
asterisk-scf/examples.git
More information about the asterisk-scf-commits
mailing list