diff options
Diffstat (limited to 'ivy.py')
-rw-r--r-- | ivy.py | 42 |
1 files changed, 39 insertions, 3 deletions
@@ -1,4 +1,6 @@ import threading +# -*- coding: iso-8859-1 -*- + #TODO #Le wrapper ne gere pas du tout les IvyClients #Il ne donne aucune information sur l'agent qui @@ -61,6 +63,7 @@ class Ivy: self.sReadyMessage=message self.sAppName=name self.dRegexp={} + self.lBindListeners=[] ivycpy.IvyInit(name, message, 0, @@ -71,11 +74,26 @@ class Ivy: #Todo Creation des objets Domaine #a partir de la chaine de caracteres self.sDomainBus=sdomainbus - ivycpy.IvyStart(sdomainbus) + ivycpy.IvySetBindCallback(self._bindCallback) + ivycpy.IvyStart(sdomainbus) def mainloop(self): ivycpy.IvyMainLoop() - + + def _bindCallback(self, client, id, regexp, event): + if (event == ivycpy.IvyAddBind ): + for bl in self.lBindListeners: + bl.bindPerformed(client, id, regexp) + elif (event == ivycpy.IvyRemoveBind ): + for bl in self.lBindListeners: + bl.unbindPerformed(client, id, regexp) + + def addBindListener(self, aBindListener): + self.lBindListeners.append(aBindListener) + + def removeBindListener(self, aBindListener): + self.lBindListeners.remove(aBindListener) + def addApplicationListener(self, aApplicationListener): self.lIvyApplicationlisteners.append(aApplicationListener) @@ -176,9 +194,27 @@ class IvyApplicationAdapter : pass def die(self,id): pass - def directMessage(self, id, msg): + def directMessage(self, client, id, msg): pass +class IvyBindAdapter : + """IvyBindAdapter + Classe d'objets abstraite définissant l'interface des objets + à fournir à l'objet de classe Ivy + via addBindListener et removeBindListener + """ + def bindPerformed(self,client, id, regexp): + """ + invoked when a Ivy Client performs a bind + """ + pass + + def unbindPerformed(self,client, id, regexp): + """ + invoked when a Ivy Client performs a unbind + """ + pass + class IvyMessageAdapter: def receive(self, client, *arg): pass |