Class AbstractSubProtocolEvent
- java.lang.Object
- java.util.EventObject
- org.springframework.context.ApplicationEvent
- org.springframework.web.socket.messaging.AbstractSubProtocolEvent
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SessionConnectedEvent
,SessionConnectEvent
,SessionDisconnectEvent
,SessionSubscribeEvent
,SessionUnsubscribeEvent
public abstract class AbstractSubProtocolEvent extends ApplicationEvent
A base class for events for a message received from a WebSocket client and parsed into a higher-level sub-protocol (e.g. STOMP).- Since:
- 4.1
- Author:
- Rossen Stoyanchev
- See Also:
- Serialized Form
Field Summary
Fields inherited from class java.util.EventObject
source
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSubProtocolEvent(Object source, Message<byte[]> message)
Create a new AbstractSubProtocolEvent.protected
AbstractSubProtocolEvent(Object source, Message<byte[]> message, Principal user)
Create a new AbstractSubProtocolEvent.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Message<byte[]>
getMessage()
Return the Message associated with the event.Principal
getUser()
Return the user for the session associated with the event.String
toString()
Methods inherited from class org.springframework.context.ApplicationEvent
getTimestamp
Methods inherited from class java.util.EventObject
getSource
Constructor Detail
AbstractSubProtocolEvent
protected AbstractSubProtocolEvent(Object source, Message<byte[]> message)
Create a new AbstractSubProtocolEvent.- Parameters:
source
- the component that published the event (nevernull
)message
- the incoming message
AbstractSubProtocolEvent
protected AbstractSubProtocolEvent(Object source, Message<byte[]> message, Principal user)
Create a new AbstractSubProtocolEvent.- Parameters:
source
- the component that published the event (nevernull
)message
- the incoming message
Method Detail
getMessage
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();
toString
public String toString()
- Overrides:
toString
in classEventObject