Top Description Fields Constructors Methods
org.springframework.web.socket.messaging

public abstract Class AbstractSubProtocolEvent

extends ApplicationEvent
Class Inheritance
Known Direct Subclasses
org.springframework.web.socket.messaging.SessionConnectedEvent, org.springframework.web.socket.messaging.SessionConnectEvent, org.springframework.web.socket.messaging.SessionDisconnectEvent, org.springframework.web.socket.messaging.SessionSubscribeEvent, org.springframework.web.socket.messaging.SessionUnsubscribeEvent
Annotations
@SuppressWarnings:serial
Imports
java.security.Principal, org.springframework.context.ApplicationEvent, org.springframework.lang.Nullable, org.springframework.messaging.Message, org.springframework.util.Assert

A base class for events for a message received from a WebSocket client and parsed into a higher-level sub-protocol (e.g. STOMP).
Author
Rossen Stoyanchev
Since
4.1

Field Summary

Modifier and TypeField and Description
private final Message<byte[]>
private final Principal

Constructor Summary

AccessConstructor and Description
protected
AbstractSubProtocolEvent(Object
the component that published the event (never null)
source
,
Message<byte[]>
the incoming message (never null)
message
)

Create a new AbstractSubProtocolEvent.

protected
AbstractSubProtocolEvent(Object
the component that published the event (never null)
source
,
Message<byte[]>
the incoming message (never null)
message
,
Principal user)

Create a new AbstractSubProtocolEvent.

Method Summary

Modifier and TypeMethod and Description
public Message<byte[]>
getMessage()

Return the Message associated with the event.

public Principal
getUser()

Return the user for the session associated with the event.

public String
toString()

Overrides java.util.EventObject.toString.

Returns a String representation of this EventObject.

Inherited from org.springframework.context.ApplicationEvent:
getTimestamp

Field Detail

messageback to summary
private final Message<byte[]> message
userback to summary
private final Principal user
Annotations
@Nullable

Constructor Detail

AbstractSubProtocolEventback to summary
protected AbstractSubProtocolEvent(Object source, Message<byte[]> message)

Create a new AbstractSubProtocolEvent.

Parameters
source:Object

the component that published the event (never null)

message:Message<byte[]>

the incoming message (never null)

AbstractSubProtocolEventback to summary
protected AbstractSubProtocolEvent(Object source, Message<byte[]> message, Principal user)

Create a new AbstractSubProtocolEvent.

Parameters
source:Object

the component that published the event (never null)

message:Message<byte[]>

the incoming message (never null)

Method Detail

getMessageback to summary
public Message<byte[]> getMessage()

Return the Message associated with the event. Here is an example of obtaining information about the session id or any headers in the message:

StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
headers.getSessionId();
headers.getSessionAttributes();
headers.getPrincipal();
getUserback to summary
public Principal getUser()

Return the user for the session associated with the event.

Annotations
@Nullable
toStringback to summary
public String toString()

Overrides java.util.EventObject.toString.

Doc from java.util.EventObject.toString.

Returns a String representation of this EventObject.

Returns:String

a String representation of this EventObject

Annotations
@Override