Пример #1
0
  def Bind(self, impl, handle):
    router = messaging.Router(handle)
    router.SetIncomingMessageReceiver(self._Stub(impl))
    error_handler = _ProxyErrorHandler()
    router.SetErrorHandler(error_handler)

    # Retain the router, until an error happen.
    retainer = _Retainer(router)
    def Cleanup(_):
      retainer.release()
    error_handler.AddCallback(Cleanup)

    # Give an instance manager to the implementation to allow it to close
    # the connection.
    impl.manager = InstanceManager(self, router, error_handler)

    router.Start()
Пример #2
0
    def setUp(self):
        super(RouterTest, self).setUp()
        self.received_messages = []
        self.received_errors = []

        def _OnMessage(message):
            self.received_messages.append(message)
            return True

        def _OnError(result):
            self.received_errors.append(result)

        handles = system.MessagePipe()
        self.router = messaging.Router(handles.handle1)
        self.router.SetIncomingMessageReceiver(
            messaging.ForwardingMessageReceiver(_OnMessage))
        self.router.SetErrorHandler(
            _ForwardingConnectionErrorHandler(_OnError))
        self.router.Start()
        self.handle = handles.handle0
Пример #3
0
 def Proxy(self, handle, version=0):
     router = messaging.Router(handle)
     error_handler = _ProxyErrorHandler()
     router.SetErrorHandler(error_handler)
     router.Start()
     return self._InternalProxy(router, error_handler, version)