Esempio n. 1
0
    def test_client_server(self):
        test_name = 'magnet-test-client-server'

        server_factory = protocol.ServerFactory()
        server_factory.protocol = wire.Echo
        self.preactor.listenMS(test_name, server_factory)

        client_creator = ClientCreator(reactor, self.preactor, RequestResponseLineReceiver)
        client = yield client_creator.connectMS(test_name)

        response = yield client.makeRequest('Is there an echo in here?')
        self.assertEqual('Is there an echo in here?', response)
Esempio n. 2
0
def main():
    from magnet.preactor import Preactor
    preactor = yield Preactor()

    # ClientCreator for connectMS
    client_creator = ClientCreator(reactor, preactor, FactorClient)
    d = client_creator.connectWorkProducer('work')
    factor_client = yield d
    

    # l = task.LoopingCall(factor_int, factor_client)
    l = task.LoopingCall(sleep_time, factor_client)
    l.start(1)
Esempio n. 3
0
def main():
    from magnet.preactor import Preactor
    preactor = yield Preactor()

    # ClientCreator for connectMS
    client_creator = ClientCreator(reactor, preactor, AddClient)
    d = client_creator.connectMS('add-service')
    add_client = yield d
    
    # use client
    add_client.add(2, 2)
    add_client.add(23, 2)
    add_client.transport.loseConnection()
    add_client.add(1000, 99999)
Esempio n. 4
0
def main():
    from magnet.preactor import Preactor
    preactor = yield Preactor()

    # ClientCreator for connectMS
    client_creator = ClientCreator(reactor, preactor, AddClient)
    d = client_creator.connectMS('add-service')
    add_client = yield d
    
    # use client
    ans = yield add_client.add(2, 2)
    log.msg('resopnse: %s' % ans)

    ans = yield add_client.add(5, 2)
    log.msg('resopnse: %s' % ans)