Example usage for org.springframework.messaging.simp.stomp ConnectionHandlingStompSession getSessionFuture

List of usage examples for org.springframework.messaging.simp.stomp ConnectionHandlingStompSession getSessionFuture

Introduction

In this page you can find the example usage for org.springframework.messaging.simp.stomp ConnectionHandlingStompSession getSessionFuture.

Prototype

ListenableFuture<StompSession> getSessionFuture();

Source Link

Document

Return a future that will complete when the session is ready for use.

Usage

From source file:org.springframework.web.socket.messaging.WebSocketStompClient.java

/**
 * An overloaded version of/*  w  ww  . j a v a 2 s  . c  o m*/
 * {@link #connect(String, WebSocketHttpHeaders, StompSessionHandler, Object...)}
 * that accepts a fully prepared {@link java.net.URI}.
 * @param url the url to connect to
 * @param handshakeHeaders the headers for the WebSocket handshake
 * @param connectHeaders headers for the STOMP CONNECT frame
 * @param sessionHandler the STOMP session handler
 * @return ListenableFuture for access to the session when ready for use
 */
public ListenableFuture<StompSession> connect(URI url, @Nullable WebSocketHttpHeaders handshakeHeaders,
        @Nullable StompHeaders connectHeaders, StompSessionHandler sessionHandler) {

    Assert.notNull(url, "'url' must not be null");
    ConnectionHandlingStompSession session = createSession(connectHeaders, sessionHandler);
    WebSocketTcpConnectionHandlerAdapter adapter = new WebSocketTcpConnectionHandlerAdapter(session);
    getWebSocketClient().doHandshake(adapter, handshakeHeaders, url).addCallback(adapter);
    return session.getSessionFuture();
}