【发布时间】:2015-11-05 13:49:16
【问题描述】:
我正在使用 Spring 的 WebSockets 的非常精简的实现。 WebSocketSession 有 getPrincipal() 方法,但是如何在 HandshakeInterceptor 中设置它?
我想把Principal放进去的方法是:
public boolean beforeHandshake(final ServerHttpRequest request, final ServerHttpResponse response, final WebSocketHandler wsHandler,
final Map<String, Object> attributes) throws Exception {
Principal = getPrincipal();
// Now where to set the principal so it is available in WebSocketSession?
}
【问题讨论】:
-
查看
DefaultHandshakeHandler的源代码:如何处理RequestUpgradeStrategy。以及任何RequestUpgradeStrategy的实现。
标签: spring-websocket