org.springframework.web.socket.messaging

## 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 org.springframework.context.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
`protected` `AbstractSubProtocolEvent(Object source, org.springframework.messaging.Message<byte[]> message)` Create a new AbstractSubProtocolEvent.
`protected` `AbstractSubProtocolEvent(Object source, org.springframework.messaging.Message<byte[]> message, Principal user)` Create a new AbstractSubProtocolEvent.

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.messaging.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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### AbstractSubProtocolEvent

    protected AbstractSubProtocolEvent(Object source,
                                       org.springframework.messaging.Message<byte[]> message)

Create a new AbstractSubProtocolEvent.

Parameters:
  `source` - the component that published the event (never `null`)
  `message` - the incoming message (never `null`)

#### AbstractSubProtocolEvent

    protected AbstractSubProtocolEvent(Object source,
                                       org.springframework.messaging.Message<byte[]> message,
                                       @Nullable
                                       Principal user)

Create a new AbstractSubProtocolEvent.

Parameters:
  `source` - the component that published the event (never `null`)
  `message` - the incoming message (never `null`)

### Method Detail

#### getMessage

    public org.springframework.messaging.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();

#### getUser

    @Nullable
    public Principal getUser()

Return the user for the session associated with the event.

#### toString

    public String toString()

Overrides:
  `toString` in class `EventObject`