def initPyroServer(self):
        Pyro.config.PYRO_ES_BLOCKQUEUE = False

        # Event listener
        Pyro.core.initClient()

        # Create publisher and subscriber links to event server
        self.publisher = LivePublisher()
        self.subscriber = LiveSubscriber(self.publisher)

        # Set the global publisher for all wrappers
        PyroWrapper.set_publisher(self.publisher)
    def __init__(self, c_instance):
        ControlSurface.__init__(self, c_instance)
        with self.component_guard():
            self.cInstance = c_instance
            self._suppress_send_midi = True

            Log.set_logger(self.log_message)
            Log.set_log_level(Log.LOG_WARN)
            Log.write("-----------------------")
            Log.write("ShowtimeBridge starting")
            Log.info(sys.version)

            self.initPyroServer()

            # Register methods to the showtimebridge server
            wrapperClasses = PyroWrapper.__subclasses__()
            wrapperClasses.append(PyroWrapper)
            for cls in wrapperClasses:  
                cls.clear_instances()
                cls.register_methods()
                for action in cls.incoming_methods().values():
                    Log.info("Adding %s to incoming callbacks" % action.methodName)
                    self.subscriber.add_incoming_action(action.methodName, cls, action.callback)
                    self.publisher.register_to_showtime(action.methodName, action.methodAccess, action.methodArgs)

                for action in cls.outgoing_methods().values():
                    Log.info("Adding %s to outgoing methods" % action.methodName)
                    self.publisher.register_to_showtime(action.methodName, action.methodAccess)

            # Midi clock to trigger incoming message check
            self.clock = PyroEncoderElement(0, 119)

            # Create the root wrapper
            PyroSong.add_instance(PyroSong(getSong()))

            self.refresh_state()
            self._suppress_send_midi = False
 def requestLoop(self):
     self.subscriber.handle_requests()
     PyroWrapper.process_deferred_actions()