Exemple #1
0
class Tester(BusHandler):
    client = None
    def connectionInitialized(self, arg):
        print "initialized"
    def connectionLost(self, arg):
        print "lost"

class MsgLogger(MessageHandler):

    def processMessage(self, msg):
        print "RECV:", type(msg), msg, msg.__dict__
        #LOGGER.info("RECV2: %s", msg.content)

    def sendDummy(self):
        self.client.send("machin", "truc", "truc-machin")

client = VigiloClient(host="localhost", user="******", password="******", log_traffic=True)
client.addHandler(Tester())
msglogger = MsgLogger()
msglogger.setClient(client)
msglogger.subscribe("truc")
msglogger.sendDummy()


def stop():
    client.stopService()
    reactor.stop()
reactor.callLater(2, stop)
application = service.Application("essai")
client.setServiceParent(application)