aboutsummaryrefslogtreecommitdiff
path: root/docs/examples/testIvy.py
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/testIvy.py')
-rw-r--r--docs/examples/testIvy.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/docs/examples/testIvy.py b/docs/examples/testIvy.py
index 6f15517..bd2a753 100644
--- a/docs/examples/testIvy.py
+++ b/docs/examples/testIvy.py
@@ -1,20 +1,36 @@
#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+"""
+Petit programme de test de la classe Ivy.Ivy
+"""
+
+import logging
+livy = logging.getLogger('Ivy')
+console = logging.StreamHandler()
+formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
+console.setFormatter(formatter)
+livy.addHandler(console)
+livy.setLevel(logging.DEBUG)
from ivy import Ivy, IvyApplicationAdapter, IvyMessageAdapter
class MyApplicationAdapter (IvyApplicationAdapter):
def connect(self, ivyclient):
print "Connexion de %s"%ivyclient.getName()
+ def die(self, ivyclient, id):
+ print "Demande de fin de l'agent recu"
class MyMessageAdapter(IvyMessageAdapter):
def receive(self, client, *arg):
print "Message --> %s"%arg[0]
-appAdapter=MyApplicationAdapter()
-bus=Ivy("tiny test","Hello World",appAdapter)
+appAdapter = MyApplicationAdapter()
+#Il ne faut pas mettre d'espace dans le nom de l'application
+#sinon die ne fonctionne pas !!
+bus = Ivy("tinytest","Hello World",appAdapter)
print "Bus %s"%bus
bus.start("")
bus()
-msgAdapter=MyMessageAdapter()
-id=bus.bindMsg("([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)",msgAdapter)
+msgAdapter = MyMessageAdapter()
+id = bus.bindMsg("([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)",msgAdapter)
bus.theThread.join(5)
-id1=bus.bindMsg("(.*)",msgAdapter)
+id1 = bus.bindMsg("(.*)",msgAdapter)
bus.theThread.join(20)