Java 基于HttpSession限制WebSocket广播的目标

Java 基于HttpSession限制WebSocket广播的目标,java,spring-boot,spring-websocket,Java,Spring Boot,Spring Websocket,我的任务是每当用户在同一浏览器、不同选项卡上注销时,向其提示“您已注销”。我目前所做的是创建一个自定义的org.springframework.security.web.authentication.logout.LogoutHandler,然后在每次触发WebSocket消息时将其广播到当前用户名下的WebSocket会话 messagingTemplate.convertAndSendToUser(username, broker + "/socket", message

我的任务是每当用户在同一浏览器、不同选项卡上注销时,向其提示“您已注销”。我目前所做的是创建一个自定义的
org.springframework.security.web.authentication.logout.LogoutHandler
,然后在每次触发WebSocket消息时将其广播到当前用户名下的WebSocket会话

messagingTemplate.convertAndSendToUser(username, broker + "/socket", message);
但是,当同一用户名在多个不同的浏览器上使用时,会遇到一个问题,比如一个在桌面上,一个在电话上。当用户同时在这两个设备上登录并从手机注销时,桌面上的WebSocket也会收到消息广播

我想要的是,比方说,我的手机上有三个标签,桌面浏览器上有两个标签,然后我注销手机,手机上的所有标签都会接收广播(因为它们共享相同的
HttpSession
),而我的桌面上的标签不会

是否有一种方法可以基于给定的
javax.servlet.http.HttpSession
(不要与
org.springframework.web.socket.WebSocketSession
)限制接收websocket客户端

我在
org.springframework.security.web.Authentication.logout.LogoutHandler
实现的方法
logout(HttpServletRequest var1,HttpServletResponse var2,Authentication var3)中广播消息,如果这很重要的话。我可以通过
var1
参数导出当前的
HttpSession