-1
我有一个网络应用程序已注册的用户,我想推动消息具有唯一用户ID的用户。为了能够将消息发送到客户端,我需要知道如何通过独特的用户ID在@sendto
注释Spring框架的网络套接字唯一@SendTo注释
这是注释
@SendTo("/topic/uniqueuserid")
public Greeting greeting(HelloMessage message) throws Exception {
int uniqueuserid;
Thread.sleep(1000); // simulated delay
return new Greeting("Hello, " + message.getName() + uniqueuserid "!");
}
和这个跺脚JS
stompClient.subscribe('/topic/uniqueuserid', function (greeting) {
showGreeting(JSON.parse(greeting.body).content);
});
如何传递唯一的用户标识@SendTo("/topic/uniqueuserid")
也许https://stackoverflow.com/questions/27047310/path-variables-in-spring-websockets-sendto-mapping – 2017-10-12 09:56:26