Tag: springwebsocket

在Spring Websocket上发送消息给特定的用户

如何将websocket消息从服务器发送到特定用户? 我的web应用程序有弹簧安全设置,并使用websocket。 我遇到了一个棘手的问题,试图从服务器发送消息到特定的用户只 。 我从阅读手册的理解是从我们可以做的服务器 simpMessagingTemplate.convertAndSend("/user/{username}/reply", reply); 而在客户端: stompClient.subscribe('/user/reply', handler); 但是我永远无法获得调用的订阅callback。 我尝试了许多不同的道路,但没有运气。 如果我把它发送到/话题/回复它的作品,但所有其他连接的用户也将收到它。 为了说明这个问题,我在github上创build了这个小项目: https : //github.com/gerrytan/wsproblem 重现步骤: 1)克隆并build立项目(确保你使用JDK 1.7和Maven 3.1) $ git clone https://github.com/gerrytan/wsproblem.git $ cd wsproblem $ mvn jetty:run 2)导航到http://localhost:8080 ,使用bob / test或者jim / testlogin 3)点击“请求用户特定的信息”。 预期:仅针对该用户的“收到的邮件给我”旁边显示“hello {用户名}”消息,实际:没有任何内容被接收