Example usage for org.springframework.web.socket.sockjs.client SockJsUrlInfo SockJsUrlInfo

List of usage examples for org.springframework.web.socket.sockjs.client SockJsUrlInfo SockJsUrlInfo

Introduction

In this page you can find the example usage for org.springframework.web.socket.sockjs.client SockJsUrlInfo SockJsUrlInfo.

Prototype

public SockJsUrlInfo(URI sockJsUrl) 

Source Link

Usage

From source file:org.springframework.web.socket.sockjs.client.SockJsClient.java

@Override
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler handler,
        @Nullable WebSocketHttpHeaders headers, URI url) {

    Assert.notNull(handler, "WebSocketHandler is required");
    Assert.notNull(url, "URL is required");

    String scheme = url.getScheme();
    if (!supportedProtocols.contains(scheme)) {
        throw new IllegalArgumentException("Invalid scheme: '" + scheme + "'");
    }/*from  w w  w  .j a  va2 s. c o m*/

    SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<>();
    try {
        SockJsUrlInfo sockJsUrlInfo = new SockJsUrlInfo(url);
        ServerInfo serverInfo = getServerInfo(sockJsUrlInfo, getHttpRequestHeaders(headers));
        createRequest(sockJsUrlInfo, headers, serverInfo).connect(handler, connectFuture);
    } catch (Throwable exception) {
        if (logger.isErrorEnabled()) {
            logger.error("Initial SockJS \"Info\" request to server failed, url=" + url, exception);
        }
        connectFuture.setException(exception);
    }
    return connectFuture;
}