spring-framework / org.springframework.messaging.simp.annotation / SendToUser

SendToUser

@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE]) class SendToUser

Annotation that indicates that the return value of a message-handling method should be sent as a org.springframework.messaging.Message to the specified destination(s) prepended with "/user/{username}" where the user name is extracted from the headers of the input message being handled.

The annotation may also be placed at class-level in which case all methods in the class where the annotation applies will inherit it.

Author
Rossen Stoyanchev

Author
Sam Brannen

Since
4.0

See Also
org.springframework.messaging.simp.annotation.support.SendToMethodReturnValueHandlerorg.springframework.messaging.simp.user.UserDestinationMessageHandlerorg.springframework.messaging.simp.SimpMessageHeaderAccessor#getUser()

Constructors

<init>

SendToUser(vararg value: String, destinations: Array<String>, broadcast: Boolean)

Annotation that indicates that the return value of a message-handling method should be sent as a org.springframework.messaging.Message to the specified destination(s) prepended with "/user/{username}" where the user name is extracted from the headers of the input message being handled.

The annotation may also be placed at class-level in which case all methods in the class where the annotation applies will inherit it.

Properties

broadcast

val broadcast: Boolean

Whether messages should be sent to all sessions associated with the user or only to the session of the input message being handled.

By default, this is set to true in which case messages are broadcast to all sessions.

destinations

val destinations: Array<String>

One or more destinations to send a message to.

If left unspecified, a default destination is selected based on the destination of the input message being handled.

value

val value: Array<String>

Alias for #destinations.