def __init__(self): super(myclient, self).__init__() self.wrapper = zmqdecorators.zmq_bonjour_connect_wrapper(zmq.DEALER, SERVICE_NAME) zmqdecorators.subscribe_topic(SERVICE_NAME, 'testsignal', self.testsignal_callback) self.pcb = ioloop_mod.PeriodicCallback(self.request_testsignal, 500) self.pcb.start()
def __init__(self): super(mysubscriber, self).__init__() zmqdecorators.subscribe_topic("test_pubsub", "bottles", self.bottles_callback) zmqdecorators.subscribe_topic("test_pubsub", "slices", self.slices_callback) zmqdecorators.subscribe_topic("test_pubsub", "noargs", self.noargs_callback) zmqdecorators.subscribe_all("test_pubsub", self.all_callback)
def __init__(self): super(myclient, self).__init__() zmqdecorators.subscribe_topic(("urpobotti.local", 7580), 'CC', self.cc_callback) zmqdecorators.subscribe_topic(("urpobotti.local", 7580), 'NORM', self.norm_callback)
def bottles_callback(data): """Since we know the exact amount and order of arguments we can get away with not adding *args. Whether adding it to avoid choking in case for channel format changes is a good idea depends on your circumstances (sometimes it's better to catch the change early""" print "in bottles_callback got %s" % repr(data) def slices_callback(data): print "in slices_callback got %s" % repr(data) def noargs_callback(): print "in noargs_callback" def all_callback(*args): """The generic callback MUST accept any number of arguments (including zero)""" print "in all_callback got %s" % repr(args) zmqdecorators.subscribe_topic("test_pubsub", "bottles", bottles_callback) zmqdecorators.subscribe_topic("test_pubsub", "slices", slices_callback) zmqdecorators.subscribe_topic("test_pubsub", "noargs", noargs_callback) zmqdecorators.subscribe_all("test_pubsub", all_callback) print "starting ioloop" ioloop.IOLoop.instance().start()