Ejemplo n.º 1
0
    def test_handshake_succeeds(self):
        """
        A client can connect to a server.
        """
        session_mock = Mock()
        t = FakeTransport()
        f = WampRawSocketClientFactory(lambda: session_mock)
        p = WampRawSocketClientProtocol()
        p.transport = t
        p.factory = f

        server_session_mock = Mock()
        st = FakeTransport()
        sf = WampRawSocketServerFactory(lambda: server_session_mock)
        sp = WampRawSocketServerProtocol()
        sp.transport = st
        sp.factory = sf

        sp.connectionMade()
        p.connectionMade()

        # Send the server the client handshake
        sp.dataReceived(t._written[0:1])
        sp.dataReceived(t._written[1:4])

        # Send the client the server handshake
        p.dataReceived(st._written)

        # The handshake succeeds, a session on each end is created
        # onOpen is called on the session
        session_mock.onOpen.assert_called_once_with(p)
        server_session_mock.onOpen.assert_called_once_with(sp)
    def test_handshake_succeeds(self):
        """
        A client can connect to a server.
        """
        session_mock = Mock()
        t = FakeTransport()
        f = WampRawSocketClientFactory(lambda: session_mock)
        p = WampRawSocketClientProtocol()
        p.transport = t
        p.factory = f

        server_session_mock = Mock()
        st = FakeTransport()
        sf = WampRawSocketServerFactory(lambda: server_session_mock)
        sp = WampRawSocketServerProtocol()
        sp.transport = st
        sp.factory = sf

        sp.connectionMade()
        p.connectionMade()

        # Send the server the client handshake
        sp.dataReceived(t._written[0:1])
        sp.dataReceived(t._written[1:4])

        # Send the client the server handshake
        p.dataReceived(st._written)

        # The handshake succeeds, a session on each end is created
        # onOpen is called on the session
        session_mock.onOpen.assert_called_once_with(p)
        server_session_mock.onOpen.assert_called_once_with(sp)
Ejemplo n.º 3
0
 def connectionLost(self, reason):
    print "X"*10
    WampRawSocketClientProtocol.connectionLost(self, reason)
    reactor.stop()
Ejemplo n.º 4
0
 def connectionMade(self):
    WampRawSocketClientProtocol.connectionMade(self)