Exemplo n.º 1
0
            def onJoin(self, details):
                # noinspection PyUnusedLocal
                def on_event(*arg, **kwargs):
                    pass

                d2 = self.subscribe(on_event, u"com.example.topic1")

                def ok(_):
                    LoopMixin.resolve_future(d, None)

                def error(err):
                    LoopMixin.reject_future(d, err)

                LoopMixin.add_future_callbacks(d2, ok, error)
Exemplo n.º 2
0
    def test_add_and_subscribe(self):
        """
      Create an application session that subscribes to some
      topic and add it to a router to run embedded.
      """
        d = LoopMixin.create_future()

        class TestSession(ApplicationSession):
            def onJoin(self, details):
                # noinspection PyUnusedLocal
                def on_event(*arg, **kwargs):
                    pass

                d2 = self.subscribe(on_event, u"com.example.topic1")

                def ok(_):
                    LoopMixin.resolve_future(d, None)

                def error(err):
                    LoopMixin.reject_future(d, err)

                LoopMixin.add_future_callbacks(d2, ok, error)

        session = TestSession(types.ComponentConfig(u"realm1"))

        self.session_factory.add(session)

        if USE_ASYNCIO:
            self.loop.run_until_complete(d)
        elif USE_TWISTED:
            return d
        else:
            raise Exception("logic error")
Exemplo n.º 3
0
    def test_add(self):
        """
      Create an application session and add it to a router to
      run embedded.
      """
        d = LoopMixin.create_future()

        class TestSession(ApplicationSession):
            def onJoin(self, details):
                LoopMixin.resolve_future(d, None)

        session = TestSession(types.ComponentConfig(u"realm1"))

        self.session_factory.add(session)

        if USE_ASYNCIO:
            self.loop.run_until_complete(d)
        elif USE_TWISTED:
            return d
        else:
            raise Exception("logic error")
Exemplo n.º 4
0
 def onJoin(self, details):
     LoopMixin.resolve_future(d, None)
Exemplo n.º 5
0
 def error(err):
     LoopMixin.reject_future(d, err)
Exemplo n.º 6
0
 def ok(_):
     LoopMixin.resolve_future(d, None)