Пример #1
0
        def inner(reactor):
            print('Creating client service')

            from twisted.internet import reactor
            endpoint = HostnameEndpoint(reactor, '127.0.0.1', self.server.port)

            client = ClientSessionService(endpoint, 'test', 'secret')
            client.subscribe('test-chan')

            print('Starting client service')
            client.startService()

            # Wait till client connected
            print('Waiting to be connected')
            yield client.whenConnected

            print('Publishing test message')
            client.publish('test-chan', b'test message')

            print('Waiting for read()')
            payload = yield client.read()
            assert ('test', 'test-chan', b'test message') == payload

            print('Stopping client')
            yield client.stopService()

            print('Stopping server for reals')
            yield self.server.close()
Пример #2
0
        def inner(reactor):
            print('Creating client service')
            endpoint = 'tcp:127.0.0.1:{}'.format(self.server.port)
            client = ClientSessionService(endpoint, 'test', 'secret')
            client.subscribe('test-chan')

            print('Starting client service')
            client.startService()

            # Wait till client connected
            print('Waiting to be connected')
            yield client.whenConnected

            print('Publishing test message')
            client.publish('test-chan', b'test message')

            print('Waiting for read()')
            payload = yield client.read()
            assert ('test', 'test-chan', b'test message') == payload

            print('Stopping client')
            yield client.stopService()

            print('Stopping server for reals')
            yield self.server.close()
Пример #3
0
        async def inner(reactor):
            print('Creating client service')
            client = ClientSessionService(f'tcp:127.0.0.1:{self.server.port}', 'test', 'secret')
            client.subscribe('test-chan')

            print('Starting client service')
            client.startService()

            # Wait till client connected
            print('Waiting to be connected')
            await client.whenConnected

            print('Publishing test message')
            client.publish('test-chan', b'test message')

            print('Waiting for read()')
            assert ('test', 'test-chan', b'test message') == client.read()

            print('Stopping client')
            await client.stopService()

            print('Stopping server for reals')
            await self.server.close()