Created
March 26, 2019 16:04
-
-
Save circlee/3b604a4d4391e4a68e0af8168a30397d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
WebSocketHandlerAdapter getWebsocketHandlerAdapter(){ | |
HandshakeWebSocketService handshakeWebSocketService = new HandshakeWebSocketService(); | |
handshakeWebSocketService.setSessionAttributePredicate( k -> true); | |
WebSocketHandlerAdapter wsha = new WebSocketHandlerAdapter(handshakeWebSocketService){ | |
@Override | |
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) { | |
Map<String, Object> attributes = exchange.getAttributes(); | |
exchange.getSession().subscribe((session) -> { | |
session.getAttributes().putAll(attributes); | |
}); | |
return super.handle(exchange, handler); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment