I want to develop a small chat with springs new websocket/stomp support. I guess i cannot use something like this:
@MessageMapping("/connect/{roomId}")
@SendTo("/topic/newMessage")
public String connectToChatRoom(@PathVariable String roomId, Principal p) {
return getTimestamp() + " " + p.getName() + " connected to the room.";
}
What are my options for dynamic mapping here? As a client i want to subscribe only to the room I'm in.
Thanks in advance!
Figured it out, you need to use @DestinationVariable instead of @PathVariable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With