Пример #1
0
    def test_ping_pong(self):
        server = MelkwegServerProtocol()
        client = MelkwegClientProtocol()

        server_fake_transport = FakeTransport()
        client_fake_transport = FakeTransport()

        server.transport = server_fake_transport
        client.transport = client_fake_transport

        client.connectionMade()
        self.assertEqual(len(client_fake_transport.buffer), 1)

        server.stringReceived(client_fake_transport.buffer[-1])
        self.assertEqual(server.status, ProtocolStatus.RUNNING)

        client.stringReceived(server_fake_transport.buffer[-1])
        self.assertEqual(client.status, ProtocolStatus.RUNNING)

        packet1 = PacketFactory.create_data_packet(1234, "hello world")
        client.write(packet1)
Пример #2
0
 def clientConnectionLost(self, connector, reason):
     logging.error("connection lost: %s" % reason)
     MelkwegClientProtocolFactory.outgoing = MelkwegClientProtocol()
     protocol.ReconnectingClientFactory.clientConnectionLost(
         self, connector, reason)
Пример #3
0
 def buildProtocol(self, addr):
     self.outgoing = MelkwegClientProtocol()
     return self.outgoing
Пример #4
0
 def buildProtocol(self, addr):
     if self.outgoing == None:
         MelkwegClientProtocolFactory.outgoing = MelkwegClientProtocol()
     return self.outgoing
Пример #5
0
 def __init__(self):
     MelkwegClientProtocolFactory.outgoing = MelkwegClientProtocol()