examples/subscriber.py
def connectToBroker(self, protocol):
        '''
        Connect to MQTT broker
        '''
        self.protocol                 = protocol
        self.protocol.onPublish       = self.onPublish
        self.protocol.onDisconnection = self.onDisconnection
        self.protocol.setWindowSize(3) 
        try:
            yield self.protocol.connect("TwistedMQTT-subs", keepalive=60)
            yield self.subscribe()
        except Exception as e:
            log.error("Connecting to {broker} raised {excp!s}", 
               broker=BROKER, excp=e)
        else:
            log.info("Connected and subscribed to {broker}", broker=BROKER)
def connectToBroker(self, protocol):
        '''
        Connect to MQTT broker
        '''
        self.protocol                 = protocol
        self.protocol.onPublish       = self.onPublish
        self.protocol.onDisconnection = self.onDisconnection
        self.protocol.setWindowSize(3) 
        try:
            yield self.protocol.connect("TwistedMQTT-subs", keepalive=60)
            yield self.subscribe()
        except Exception as e:
            log.error("Connecting to {broker} raised {excp!s}", 
               broker=BROKER, excp=e)
        else:
            log.info("Connected and subscribed to {broker}", broker=BROKER)
def connectToBroker ( self , protocol ) : self . protocol = protocol self . protocol . onPublish = self . onPublish self . protocol . onDisconnection = self . onDisconnection self . protocol . setWindowSize ( 3 ) try : yield self . protocol . connect ( "TwistedMQTT-subs" , keepalive = 60 ) yield self . subscribe ( ) except Exception as e : log . error ( "Connecting to {broker} raised {excp!s}" , broker = BROKER , excp = e ) else : log . info ( "Connected and subscribed to {broker}" , broker = BROKER )
Connect to MQTT broker
Connect to MQTT broker