Examples of WebSocketClient


Examples of org.eclipse.jetty.websocket.client.WebSocketClient

  public void start(Target target, String loggregatorLocation, LoggregatorListener listener) throws Exception {
    logger.debug(NLS.bind("About to connect: {0}", loggregatorLocation));

    SslContextFactory sslContextFactory = new SslContextFactory(true);
    WebSocketClient client = new WebSocketClient(sslContextFactory);
    LoggregatorSocket socket = new LoggregatorSocket(listener);
    try {
      client.start();
      URI loggregatorUri = new URI(loggregatorLocation);
      ClientUpgradeRequest request = new ClientUpgradeRequest();
      request.setHeader("Authorization", "bearer " + target.getCloud().getAccessToken().getString("access_token"));

      client.connect(socket, loggregatorUri, request);
      logger.debug(NLS.bind("Connecting to: {0}", loggregatorUri));
      socket.awaitClose(5, TimeUnit.SECONDS);
    } finally {
      client.stop();
    }
  }
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

            case JSR_WS_TRANSPORT:
                wsClientContainer = ContainerProvider.getWebSocketContainer();
                server.addBean(wsClientContainer);
                break;
            case JETTY_WS_TRANSPORT:
                wsClient = new WebSocketClient();
                server.addBean(wsClient);
                break;
            default:
                throw new AssertionError();
        }
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

                httpClient.addBean(wsClientContainer, true);
                break;
            case WEBSOCKET_JETTY:
                wsThreadPool = new QueuedThreadPool();
                wsThreadPool.setName(wsThreadPool.getName() + "-client");
                wsClient = new WebSocketClient();
                wsClient.setExecutor(wsThreadPool);
                httpClient.addBean(wsClient);
                break;
            default:
                throw new IllegalArgumentException();
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

    }

    public void start() throws Exception
    {
        threadPool = new QueuedThreadPool();
        wsClient = new WebSocketClient();
        wsClient.setExecutor(threadPool);
        wsClient.setMasker(new ZeroMasker());
        wsClient.start();
    }
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

        webSocketContainer = ContainerProvider.getWebSocketContainer();
        // Make sure the container is stopped when the HttpClient is stopped
        httpClient.addBean(webSocketContainer, true);
        mbeanContainer.beanAdded(null, webSocketContainer);

        webSocketClient = new WebSocketClient();
        webSocketClient.setExecutor(threadPool);
        webSocketClient.setMasker(new ZeroMasker());
        webSocketClient.getPolicy().setInputBufferSize(8 * 1024);
        webSocketClient.addBean(mbeanContainer);
        webSocketClient.start();
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

        decoderFactory.init(empty);
        encoderFactory.init(empty);

        boolean trustAll = Boolean.getBoolean("org.eclipse.jetty.websocket.jsr356.ssl-trust-all");
       
        client = new WebSocketClient(new SslContextFactory(trustAll), executor);
        client.setEventDriverFactory(new JsrEventDriverFactory(client.getPolicy()));
        client.setSessionFactory(new JsrSessionFactory(this,this,client));
        addBean(client);

        ShutdownThread.register(this);
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

        return engine;
    }

    public UpgradeConnection newUpgradeConnection(SocketChannel channel, EndPoint endPoint, ConnectPromise connectPromise)
    {
        WebSocketClient client = connectPromise.getClient();
        Executor executor = client.getExecutor();
        UpgradeConnection connection = new UpgradeConnection(endPoint,executor,connectPromise);
        return connection;
    }
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

    private ServiceSocket getConnectionSocket() throws URISyntaxException, Exception {
        URI uri = getUri();

        String connectionId = getThreadName() + getConnectionId();
        ServiceSocket socket;
        WebSocketClient webSocketClient;
        if (isStreamingConnection()) {
             if (connectionList.containsKey(connectionId)) {
                 socket = connectionList.get(connectionId);
                 socket.initialize();
                 return socket;
             } else {
                socket = new ServiceSocket(this);
                connectionList.put(connectionId, socket);
             }
        } else {
            socket = new ServiceSocket(this);
        }

        SslContextFactory sslContexFactory = new SslContextFactory();
        sslContexFactory.setTrustAll(isIgnoreSslErrors());
        webSocketClient = new WebSocketClient(sslContexFactory);
       
        webSocketClient.start();
        ClientUpgradeRequest request = new ClientUpgradeRequest();
        webSocketClient.connect(socket, uri, request);
       
        int connectionTimeout = Integer.parseInt(getConnectionTimeout());
        socket.awaitOpen(connectionTimeout, TimeUnit.MILLISECONDS);
       
        return socket;
View Full Code Here

Examples of org.eclipse.jetty.websocket.client.WebSocketClient

        ServiceSocket socket;

        //Create WebSocket client
        SslContextFactory sslContexFactory = new SslContextFactory();
        sslContexFactory.setTrustAll(isIgnoreSslErrors());
        WebSocketClient webSocketClient = new WebSocketClient(sslContexFactory);       
       
        if (isStreamingConnection()) {
             if (connectionList.containsKey(connectionId)) {
                 socket = connectionList.get(connectionId);
                 socket.initialize();
                 return socket;
             } else {
                socket = new ServiceSocket(this, webSocketClient);
                connectionList.put(connectionId, socket);
             }
        } else {
            socket = new ServiceSocket(this, webSocketClient);
        }

        //Start WebSocket client thread and upgrage HTTP connection
        webSocketClient.start();
        ClientUpgradeRequest request = new ClientUpgradeRequest();
        webSocketClient.connect(socket, uri, request);
       
        //Get connection timeout or use the default value
        int connectionTimeout;
        try {
            connectionTimeout = Integer.parseInt(getConnectionTimeout());
View Full Code Here

Examples of org.java_websocket.client.WebSocketClient

    //for legacy code, to be able pass connection only
    private RmiProxy rmiProxy;

    public Connection(final String username, URI uri, MessageListener _listener) {
        this.listener = _listener;
        ws = new WebSocketClient(uri) {
            @Override
            public void onClose(int code, String reason, boolean remote) {
                listener.onWebsocketClose(code, reason, remote);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.