Websocket拦截器HandshakeInterceptor

https://www.jianshu.com/p/7c98820f0364

org.springframework.web.socket.server

Interface HandshakeInterceptor

所有已知实现类

HttpSessionHandshakeInterceptor


public interface HandshakeInterceptor
WebSocket握手请求的拦截器. 检查握手请求和响应, 对WebSocketHandler传递属性


  • boolean beforeHandShake(ServerHttpRequest request,ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception
    在握手之前执行该方法, 继续握手返回true, 中断握手返回false. 通过attributes参数设置WebSocketSession的属性
  • void afterHandshake(ServerHttpRequest request,ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception
    在握手之后执行该方法. 无论是否握手成功都指明了响应状态码和相应头.


作者:写java的逗比叫z1
链接:https://www.jianshu.com/p/7c98820f0364
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
原文地址:https://www.cnblogs.com/handsome1013/p/9389127.html