Package org.cometd.client.transport

Examples of org.cometd.client.transport.ClientTransport


    @Test
    public void testClientCanNegotiateTransportWithServerNotSupportingWebSocket() throws Exception
    {
        bayeux.setAllowedTransports("long-polling");

        final ClientTransport webSocketTransport = newWebSocketTransport(null);
        final ClientTransport longPollingTransport = newLongPollingTransport(null);
        final CountDownLatch failureLatch = new CountDownLatch(1);
        final BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport, longPollingTransport)
        {
            @Override
            protected void onTransportFailure(String oldTransportName, String newTransportName, Throwable failure)
            {
                Assert.assertEquals(webSocketTransport.getName(), oldTransportName);
                Assert.assertEquals(longPollingTransport.getName(), newTransportName);
                failureLatch.countDown();
            }
        };

        final CountDownLatch successLatch = new CountDownLatch(1);
View Full Code Here


    @Test
    public void testClientWithOnlyWebSocketCannotNegotiateWithServerNotSupportingWebSocket() throws Exception
    {
        bayeux.setAllowedTransports("long-polling");

        final ClientTransport webSocketTransport = newWebSocketTransport(null);
        final CountDownLatch failureLatch = new CountDownLatch(1);
        final BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport)
        {
            @Override
            protected void onTransportFailure(String oldTransportName, String newTransportName, Throwable failure)
            {
                Assert.assertEquals(webSocketTransport.getName(), oldTransportName);
                Assert.assertNull(newTransportName);
                failureLatch.countDown();
            }
        };
View Full Code Here

    @Test
    public void testClientRetriesWebSocketTransportIfCannotConnect() throws Exception
    {
        final CountDownLatch connectLatch = new CountDownLatch(2);
        ClientTransport webSocketTransport = newWebSocketTransport(null);
        webSocketTransport.setOption(JettyWebSocketTransport.CONNECT_TIMEOUT_OPTION, 1000L);
        ClientTransport longPollingTransport = newLongPollingTransport(null);
        final BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport, longPollingTransport)
        {
            @Override
            protected boolean sendConnect()
            {
View Full Code Here

    }

    @Test
    public void testRestart() throws Exception
    {
        ClientTransport webSocketTransport = newWebSocketTransport(null);
        ClientTransport longPollingTransport = newLongPollingTransport(null);
        final BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport, longPollingTransport);

        final AtomicReference<CountDownLatch> connectedLatch = new AtomicReference<>(new CountDownLatch(1));
        final AtomicReference<CountDownLatch> disconnectedLatch = new AtomicReference<>(new CountDownLatch(2));
        client.getChannel(Channel.META_CONNECT).addListener(new ClientSessionChannel.MessageListener()
View Full Code Here

    public void testRestartAfterConnectWithFatalException() throws Exception
    {
        // ConnectException is a recoverable exception that does not disable the transport.
        // Convert it to a fatal exception so the transport would be disabled.
        // However, since it connected before this fatal exception, the transport is not disabled.
        ClientTransport webSocketTransport;
        switch (wsTransportType)
        {
            case WEBSOCKET_JSR_356:
                webSocketTransport = new org.cometd.websocket.client.WebSocketTransport(null, null, wsClientContainer)
                {
View Full Code Here

            }
        });

        Map<String,Object> options = new HashMap<>();
        options.put(ClientTransport.MAX_NETWORK_DELAY_OPTION, maxNetworkDelay);
        ClientTransport webSocketTransport = newWebSocketTransport(options);
        final BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport);

        // Expect 2 failed messages because the client backoffs and retries
        // This way we are sure that the late response from the first
        // expired handshake is not delivered to listeners
View Full Code Here

        }
        prepareAndStart(initParams);

        Map<String, Object> options = new HashMap<>();
        options.put("ws.maxNetworkDelay", maxNetworkDelay);
        ClientTransport webSocketTransport = newWebSocketTransport(options);
        BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport);
        client.setOption(BayeuxClient.BACKOFF_INCREMENT_OPTION, backoffIncrement);

        bayeux.getChannel(Channel.META_CONNECT).addListener(new ServerChannel.MessageListener()
        {
View Full Code Here

        serverOptions.put("ws.maxMessageSize", String.valueOf(maxMessageSize));
        prepareAndStart(serverOptions);

        Map<String, Object> clientOptions = new HashMap<>();
        clientOptions.put("ws.maxMessageSize", maxMessageSize);
        ClientTransport webSocketTransport = newWebSocketTransport(clientOptions);
        BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport);

        client.handshake();
        Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));
View Full Code Here

        });

        final long maxNetworkDelay = 2000L;
        Map<String, Object> clientOptions = new HashMap<>();
        clientOptions.put("maxNetworkDelay", maxNetworkDelay);
        ClientTransport webSocketTransport = newWebSocketTransport(clientOptions);
        BayeuxClient client = new BayeuxClient(cometdURL, webSocketTransport);

        client.handshake();
        Assert.assertTrue(client.waitFor(5000, BayeuxClient.State.CONNECTED));
View Full Code Here

        List<ClientTransport> transports = new ArrayList<>();
        for (ClientTransport.Factory factory : getClientTransportFactories())
            transports.add(factory.newClientTransport(cometURL, options));

        ClientTransport transport = transports.get(0);
        int size = transports.size();
        ClientTransport[] otherTransports = transports.subList(1, size).toArray(new ClientTransport[size - 1]);

        return new OortComet(this, cometURL, _scheduler, transport, otherTransports);
    }
View Full Code Here

TOP

Related Classes of org.cometd.client.transport.ClientTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.