我有一个简单的使用stomp的web套接字应用程序。当用户访问一个页面时,它会自动与服务器建立连接。用户通过弹簧安全进行身份验证。当用户关闭浏览器时,我希望用户自动注销。为此,我创建一个侦听器来侦听SessionDisconnectEvent。问题是我没有与websocket会话相关的httpSession的句柄?是否有想从websocket会话获取httpsession?在春天获取关联的websocket会话的HTTPSession
这里是我的代码:
<websocket:message-broker application-destination-prefix="/test">
<websocket:stomp-endpoint path="/sbapp">
<websocket:handshake-interceptors>
<bean class="com.sample.HttpSessionIdHandshakeInterceptor"></bean>
</websocket:handshake-interceptors>
<websocket:sockjs />
</websocket:stomp-endpoint>
<websocket:stomp-broker-relay prefix="/topic,/queue,/user" relay-host="localhost" relay-port="61613"/>
</websocket:message-broker>
,这里是我的WebSocket会话监听器:
@Component
public class StompDisconnectListener implements ApplicationListener<SessionDisconnectEvent>{
@Override
public void onApplicationEvent(SessionDisconnectEvent event) {
System.out.println("Stomp disconnect: " + event.getSessionId());
}
}
我需要的方式,例如,当我得到得到一个断开事件我手动得到相应的HttpSession然后注销的HttpSession中。这可能吗?
您是否发现这个问题的体面解决方案?在这里碰到相同的用例。 – proulxs 2015-03-10 20:46:45
我也对这个问题的解决方案感兴趣。你最终如何解决它? – Fooble 2016-08-05 03:50:28