【发布时间】:2014-02-14 05:45:40
【问题描述】:
我正在试验 Spring 4 WebSocket STOMP 应用程序。有没有办法在每个用户都有唯一的会话 ID 的情况下回复单个未经身份验证的用户?现在我只能广播消息或将其直接发送给经过身份验证的用户。
@Controller
public class ProductController {
@MessageMapping("/products/{id}")
@SendTo("/topic") // This line makes return value to be broadcasted to every connected user.
public String getProduct(@DestinationVariable int id) {
return "Product " + id;
}
}
【问题讨论】:
-
或者我对同一问题的替代答案 [Spring Websockets @SendToUser 无需登录?](stackoverflow.com/a/43430736/1847378)
标签: spring websocket stomp spring-messaging spring-websocket