Reputation: 21380
I would like to implement a chat using Spring websockets. What will be the best way to implement groups?
UserDestinationMessageHandler
for URLs like /group/{groupname}/queue/*
and create a new UserDestinationResolver
. Are there any examples for this?ApplicationListener<SessionConnectedEvent>
. But how can I get the session attributes from the event?In both options I was taking into account that I will register the group to which the user belongs into session attributes.
Upvotes: 2
Views: 1098
Reputation: 21380
I ended up creating a destination like "/topic/group/{name}/message" managed by message broker and have user subscribed to it. To send a message you can either send it to the same destination or you can send it to a destination like "/app/message" and have it forward it from there. The latter option has the advantage that you can filter the message.
Upvotes: 2