def onJoin(self, details): def on_event(*arg, **kwargs): pass d2 = self.subscribe(on_event, u'com.example.topic1') def ok(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error)
def onJoin(self, details): def on_event(*arg, **kwargs): pass d2 = self.subscribe(on_event, u'com.example.topic1') def ok(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error)
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 = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): def on_event(*arg, **kwargs): pass d2 = self.subscribe(on_event, u'com.example.topic1') def ok(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error) session = TestSession(types.ComponentConfig('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")
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 = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): def on_event(*arg, **kwargs): pass d2 = self.subscribe(on_event, u'com.example.topic1') def ok(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error) session = TestSession(types.ComponentConfig('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")
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 = FutureMixin._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(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error) session = TestSession(types.ComponentConfig(u"realm1")) self.session_factory.add(session) return d
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 = FutureMixin._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(_): FutureMixin._resolve_future(d, None) def error(err): FutureMixin._reject_future(d, err) FutureMixin._add_future_callbacks(d2, ok, error) session = TestSession(types.ComponentConfig(u'realm1')) self.session_factory.add(session) return d
def test_add(self): """ Create an application session and add it to a router to run embedded. """ d = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): FutureMixin._resolve_future(d, None) session = TestSession(types.ComponentConfig(u"realm1")) self.session_factory.add(session) return d
def test_add(self): """ Create an application session and add it to a router to run embedded. """ d = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): FutureMixin._resolve_future(d, None) session = TestSession(types.ComponentConfig(u'realm1')) self.session_factory.add(session) return d
def test_add(self): """ Create an application session and add it to a router to run embedded. """ d = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): FutureMixin._resolve_future(d, None) session = TestSession(types.ComponentConfig('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")
def test_add(self): """ Create an application session and add it to a router to run embedded. """ d = FutureMixin._create_future() class TestSession(ApplicationSession): def onJoin(self, details): FutureMixin._resolve_future(d, None) session = TestSession(types.ComponentConfig('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")
def onJoin(self, details): FutureMixin._resolve_future(d, None)
def error(err): FutureMixin._reject_future(d, err)
def ok(_): FutureMixin._resolve_future(d, None)
def error(err): FutureMixin._reject_future(d, err)
def ok(_): FutureMixin._resolve_future(d, None)
def onJoin(self, details): FutureMixin._resolve_future(d, None)