Ejemplo n.º 1
0
    def main(self):
        yield 1

        while 1:
            if self.dataReady("control"):
                mes = self.recv("control")
                
                if isinstance(mes, shutdownMicroprocess) or isinstance(mes, producerFinished):
                    self.send(producerFinished(), "signal")
                    break

            if self.dataReady("forward"):
                s = self.recv("forward")
                self.send(Node.to_subscription_element(s), "outbox")

            if self.dataReady("inbox"):
                handled = False
                a = self.recv("inbox")
                e = a.xml_parent.xml_parent
                self.send(('INCOMING', e), "log")
                
                msg_type = e.get_attribute_value(u'type') or 'get'
                key = 'xmpp.%s' % unicode(msg_type)

                if key in self.outboxes:
                    self.send(Node.from_subscription_element(e), key)
                    handled = True

                if not handled:
                    self.send(e, "unknown")
                    
            if not self.anyReady():
                self.pause()
  
            yield 1

        yield 1