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.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(org.springframework.web.server.ServerWebExchange exchange,
WebSocketHandler handler)
Handle the HTTP request and use the given
WebSocketHandler . |
boolean |
isRunning() |
void |
start() |
void |
stop() |
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()
start
in interface org.springframework.context.Lifecycle
protected void doStart()
public void stop()
stop
in interface org.springframework.context.Lifecycle
protected void doStop()
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public reactor.core.publisher.Mono<Void> handleRequest(org.springframework.web.server.ServerWebExchange exchange, WebSocketHandler handler)
WebSocketService
WebSocketHandler
.handleRequest
in interface WebSocketService
exchange
- the current exchangehandler
- handler for WebSocket session