문제

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

다른 팁

Yes the @MessageMapping annotation (javaadoc) and the reference docs both list all supported arguments and return value types.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top