Example usage for org.springframework.web.reactive.socket WebSocketSession getId

List of usage examples for org.springframework.web.reactive.socket WebSocketSession getId

Introduction

In this page you can find the example usage for org.springframework.web.reactive.socket WebSocketSession getId.

Prototype

String getId();

Source Link

Document

Return the id for the session.

Usage

From source file:org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient.java

@Override
public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) {
    return getHttpClient().headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders))
            .websocket(StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols()))
            .uri(url.toString()).handle((inbound, outbound) -> {
                HttpHeaders responseHeaders = toHttpHeaders(inbound);
                String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol");
                HandshakeInfo info = new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol);
                NettyDataBufferFactory factory = new NettyDataBufferFactory(outbound.alloc());
                WebSocketSession session = new ReactorNettyWebSocketSession(inbound, outbound, info, factory);
                if (logger.isDebugEnabled()) {
                    logger.debug("Started session '" + session.getId() + "' for " + url);
                }/* w  w  w . j  av a 2  s  .  c o  m*/
                return handler.handle(session);
            }).doOnRequest(n -> {
                if (logger.isDebugEnabled()) {
                    logger.debug("Connecting to " + url);
                }
            }).next();
}