org.springframework.web.reactive.socket.server.support

## Class HandshakeWebSocketService

- java.lang.Object
- - org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService

All Implemented Interfaces:
  org.springframework.context.Lifecycle, WebSocketService

    public class HandshakeWebSocketService
    extends Object
    implements WebSocketService, org.springframework.context.Lifecycle

`WebSocketService` implementation that handles a WebSocket HTTP handshake request by delegating to a `RequestUpgradeStrategy` which is either auto-detected (no-arg constructor) from the classpath but can also be explicitly configured.

Since:
  5.0
Author:
  Rossen Stoyanchev

### Field Summary

Fields
`protected static Log` `logger`

### Constructor Summary

Constructors
Constructor and Description
`HandshakeWebSocketService()` Default constructor automatic, classpath detection based discovery of the `RequestUpgradeStrategy` to use.
`HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy)` Alternative constructor with the `RequestUpgradeStrategy` to use.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `doStart()`
`protected void` `doStop()`
`Predicate<String>` `getSessionAttributePredicate()` Return the configured predicate for initialization WebSocket session attributes from `WebSession` attributes.
`RequestUpgradeStrategy` `getUpgradeStrategy()` Return the `RequestUpgradeStrategy` for WebSocket requests.
`reactor.core.publisher.Mono<Void>` `handleRequest(org.springframework.web.server.ServerWebExchange exchange, WebSocketHandler handler)` Handle the request with the given `WebSocketHandler`.
`boolean` `isRunning()`
`void` `setSessionAttributePredicate(Predicate<String> predicate)` Configure a predicate to use to extract `WebSession` attributes and use them to initialize the WebSocket session with.
`void` `start()`
`void` `stop()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### logger

    protected static final Log logger

### Constructor Detail

#### HandshakeWebSocketService

    public HandshakeWebSocketService()

Default constructor automatic, classpath detection based discovery of the `RequestUpgradeStrategy` to use.

#### HandshakeWebSocketService

    public HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy)

Alternative constructor with the `RequestUpgradeStrategy` to use.

Parameters:
  `upgradeStrategy` - the strategy to use

### Method Detail

#### getUpgradeStrategy

    public RequestUpgradeStrategy getUpgradeStrategy()

Return the `RequestUpgradeStrategy` for WebSocket requests.

#### setSessionAttributePredicate

    public void setSessionAttributePredicate(@Nullable
                                             Predicate<String> predicate)

Configure a predicate to use to extract `WebSession` attributes and use them to initialize the WebSocket session with.

By default this is not set in which case no attributes are passed.

Parameters:
  `predicate` - the predicate
Since:
  5.1

#### getSessionAttributePredicate

    @Nullable
    public Predicate<String> getSessionAttributePredicate()

Return the configured predicate for initialization WebSocket session attributes from `WebSession` attributes.

Since:
  5.1

#### start

    public void start()

Specified by:
  `start` in interface `org.springframework.context.Lifecycle`

#### doStart

    protected void doStart()

#### stop

    public void stop()

Specified by:
  `stop` in interface `org.springframework.context.Lifecycle`

#### doStop

    protected void doStop()

#### isRunning

    public boolean isRunning()

Specified by:
  `isRunning` in interface `org.springframework.context.Lifecycle`

#### handleRequest

    public reactor.core.publisher.Mono<Void> handleRequest(org.springframework.web.server.ServerWebExchange exchange,
                                                           WebSocketHandler handler)

Description copied from interface: `WebSocketService`
Handle the request with the given `WebSocketHandler`.

Specified by:
  `handleRequest` in interface `WebSocketService`
Parameters:
  `exchange` - the current exchange
  `handler` - handler for WebSocket session
Returns:
  a `Mono<Void>` that completes when application handling of the WebSocket session completes.