接口 HandshakeInterceptor
public interface HandshakeInterceptor
Interceptor for WebSocket handshake requests. Can be used to inspect the handshake request and response as well as to pass attributes to the targetWebSocketHandler.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
- 另请参阅:
WebSocketHttpRequestHandler,DefaultSockJsService
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidafterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception)Invoked after the handshake is done.booleanbeforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String,Object> attributes)Invoked before the handshake is processed.
方法详细资料
beforeHandshake
boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String,Object> attributes) throws Exception
Invoked before the handshake is processed.- 参数:
request- the current requestresponse- the current responsewsHandler- the target WebSocket handlerattributes- the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.- 返回:
- whether to proceed with the handshake (
true) or abort (false) - 抛出:
Exception
afterHandshake
void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, @Nullable Exception exception)
Invoked after the handshake is done. The response status and headers indicate the results of the handshake, i.e. whether it was successful or not.- 参数:
request- the current requestresponse- the current responsewsHandler- the target WebSocket handlerexception- an exception raised during the handshake, ornullif none