Websocket(3)拦截器
4、拦截器
1 public class HandshakeInterceptor extends HttpSessionHandshakeInterceptor { 2 3 public static final String HTTP_SESSION_KEY_MMY = "HTTP_SESSION_KEY_MMY"; 4 // 握手前 5 @Override 6 public boolean beforeHandshake(ServerHttpRequest request, 7 ServerHttpResponse response, WebSocketHandler wsHandler, 8 Map<String, Object> attributes) throws Exception { 9 System.out.println("++++++++++++++++ HandshakeInterceptor: beforeHandshake ++++++++++++++"+attributes);13 return super.beforeHandshake(request, response, wsHandler, attributes); 14 } 15 16 17 18 // 握手后 19 @Override 20 public void afterHandshake(ServerHttpRequest request, 21 ServerHttpResponse response, WebSocketHandler wsHandler, 22 Exception ex) { 23 24 25 System.out.println("++++++++++++++++ HandshakeInterceptor: afterHandshake ++++++++++++++"); 26 27 28 super.afterHandshake(request, response, wsHandler, ex); 29 30 } 31 }