类 WebSocketHandlerAdapter
- java.lang.Object
- org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter
- 所有已实现的接口:
HandlerAdapter
public class WebSocketHandlerAdapter extends Object implements HandlerAdapter
HandlerAdapter
that allows using aWebSocketHandler
with the genericDispatcherHandler
mapping URLs directly to such handlers. Requests are handled by delegating to the configuredWebSocketService
which by default isHandshakeWebSocketService
.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 WebSocketHandlerAdapter()
Default constructor that creates and uses aHandshakeWebSocketService
.WebSocketHandlerAdapter(WebSocketService webSocketService)
Alternative constructor with theWebSocketService
to use.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 WebSocketService
getWebSocketService()
Return the configuredWebSocketService
to handle requests.reactor.core.publisher.Mono<HandlerResult>
handle(ServerWebExchange exchange, Object handler)
Handle the request with the given handler.boolean
supports(Object handler)
Whether thisHandlerAdapter
supports the givenhandler
.
构造器详细资料
WebSocketHandlerAdapter
public WebSocketHandlerAdapter()
Default constructor that creates and uses aHandshakeWebSocketService
.
WebSocketHandlerAdapter
public WebSocketHandlerAdapter(WebSocketService webSocketService)
Alternative constructor with theWebSocketService
to use.
方法详细资料
getWebSocketService
public WebSocketService getWebSocketService()
Return the configuredWebSocketService
to handle requests.
supports
public boolean supports(Object handler)
从接口复制的说明:HandlerAdapter
Whether thisHandlerAdapter
supports the givenhandler
.- 指定者:
supports
在接口中HandlerAdapter
- 参数:
handler
- the handler object to check- 返回:
- whether or not the handler is supported
handle
public reactor.core.publisher.Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler)
从接口复制的说明:HandlerAdapter
Handle the request with the given handler.Implementations are encouraged to handle exceptions resulting from the invocation of a handler in order and if necessary to return an alternate result that represents an error response.
Furthermore since an async
HandlerResult
may produce an error later during result handling implementations are also encouraged toset an exception handler
on theHandlerResult
so that may also be applied later after result handling.- 指定者:
handle
在接口中HandlerAdapter
- 参数:
exchange
- current server exchangehandler
- the selected handler which must have been previously checked viaHandlerAdapter.supports(Object)
- 返回:
Mono
that emits a singleHandlerResult
or none if the request has been fully handled and doesn't require further handling.