public class HandshakeWebSocketService extends Object implements WebSocketService, 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.| 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. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
protected void |
doStop() |
RequestUpgradeStrategy |
getUpgradeStrategy()
Return the
RequestUpgradeStrategy for WebSocket requests. |
reactor.core.publisher.Mono<Void> |
handleRequest(ServerWebExchange exchange,
WebSocketHandler handler)
Handle the HTTP request and use the given
WebSocketHandler. |
boolean |
isRunning()
Check whether this component is currently running.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method.
|
protected static final Log logger
public HandshakeWebSocketService()
RequestUpgradeStrategy to use.public HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy)
RequestUpgradeStrategy to use.upgradeStrategy - the strategy to usepublic RequestUpgradeStrategy getUpgradeStrategy()
RequestUpgradeStrategy for WebSocket requests.public void start()
LifecycleShould not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
start in interface LifecycleSmartLifecycle.isAutoStartup()protected void doStart()
public void stop()
LifecycleSmartLifecycle
and its stop(Runnable) variant when asynchronous stop behavior is necessary.
Note that this stop notification is not guaranteed to come before destruction:
On regular shutdown, Lifecycle beans will first receive a stop notification
before the general destruction callbacks are being propagated; however, on hot
refresh during a context's lifetime or on aborted refresh attempts, a given bean's
destroy method will be called without any consideration of stop signals upfront.
Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable),
DisposableBean.destroy()protected void doStop()
public boolean isRunning()
LifecycleIn the case of a container, this will return true only if all
components that apply are currently running.
public reactor.core.publisher.Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler handler)
WebSocketServiceWebSocketHandler.handleRequest in interface WebSocketServiceexchange - the current exchangehandler - handler for WebSocket session