10

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?

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.

Kristof
  • 1,684
  • 2
  • 23
  • 49

3 Answers3

9

There is a reasonable spring blog post which covers this: http://assets.spring.io/wp/WebSocketBlogPost.html

The source code is on github (and linked from the blog).

Jaimie Whiteside
  • 1,180
  • 9
  • 21
2

There is a concept of User Destinations where messages can be bound to a specific destination belonging to a user's session.

There is this article from the Spring docs that explains it nicely. Hope this helps someone.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
0

For anyone looking for the same answer with a nice code example, I've found this repo: spring-websocket-chat

ttarczynski
  • 949
  • 1
  • 10
  • 19