使用 Spring STOMP websockets 向单身人士发送消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21443679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sending message to single person using Spring STOMP websockets
提问by Kristof
On the internet I've found some info on how to accept and send messages using Spring and STOMP, however I did not find any good examples on how to send a message to a single user. Only how to broadcast them to every single one. Are there any good examples on it?
在互联网上,我找到了一些关于如何使用 Spring 和 STOMP 接受和发送消息的信息,但是我没有找到任何关于如何向单个用户发送消息的好例子。只有如何将它们广播给每一个人。有什么好的例子吗?
I basically want to run one or two controllers with STOMP in a Spring MVC structure, so I can authenticate people outside of the websocket, and later on tie that authentication to the STOMP controllers, and for that I obviously need to be able to send messages to individuals.
我基本上想在 Spring MVC 结构中使用 STOMP 运行一两个控制器,这样我就可以对 websocket 之外的人进行身份验证,然后将该身份验证与 STOMP 控制器联系起来,为此我显然需要能够发送消息对个人。
采纳答案by Jaimie Whiteside
There is a reasonable spring blog post which covers this: http://assets.spring.io/wp/WebSocketBlogPost.html
有一个合理的春季博客文章,涵盖了这一点:http: //assets.spring.io/wp/WebSocketBlogPost.html
The source code is on github (and linked from the blog).
源代码在 github 上(并从博客链接)。
回答by Abdullah Khan
回答by ttarczynski
For anyone looking for the same answer with a nice code example, I've found this repo: spring-websocket-chat
对于任何通过一个很好的代码示例寻找相同答案的人,我找到了这个 repo:spring-websocket-chat