public class StompProtocolHandler extends Object implements SubProtocolHandler
SubProtocolHandler
for STOMP that supports versions 1.0, 1.1, and 1.2 of the
STOMP specification.Modifier and Type | Field and Description |
---|---|
static String |
CONNECTED_USER_HEADER
The name of the header set on the CONNECTED frame indicating the name of the user
authenticated on the WebSocket session.
|
static String |
QUEUE_SUFFIX_HEADER
A suffix unique to the current session that a client can use to append to
a destination to make it unique.
|
Constructor and Description |
---|
StompProtocolHandler() |
Modifier and Type | Method and Description |
---|---|
void |
afterSessionEnded(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.CloseStatus closeStatus,
MessageChannel outputChannel)
Invoked after a
WebSocketSession has ended. |
void |
afterSessionStarted(org.springframework.web.socket.WebSocketSession session,
MessageChannel outputChannel)
Invoked after a
WebSocketSession has started. |
List<String> |
getSupportedProtocols()
Return the list of sub-protocols supported by this handler, never
null . |
MutableUserQueueSuffixResolver |
getUserQueueSuffixResolver() |
void |
handleMessageFromClient(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.WebSocketMessage webSocketMessage,
MessageChannel outputChannel)
Handle incoming WebSocket messages from clients.
|
void |
handleMessageToClient(org.springframework.web.socket.WebSocketSession session,
Message<?> message)
Handle STOMP messages going back out to WebSocket clients.
|
String |
resolveSessionId(Message<?> message)
Resolve the session id from the given message or return
null . |
protected void |
sendErrorMessage(org.springframework.web.socket.WebSocketSession session,
Throwable error) |
void |
setUserQueueSuffixResolver(MutableUserQueueSuffixResolver resolver)
Configure a resolver to use to maintain queue suffixes for user
|
public static final String CONNECTED_USER_HEADER
public static final String QUEUE_SUFFIX_HEADER
org.springframework.messaging.simp.handler.UserDestinationMessageHandler}
,
Constant Field Valuespublic void setUserQueueSuffixResolver(MutableUserQueueSuffixResolver resolver)
org.springframework.messaging.simp.handler.UserDestinationMessageHandler}
public MutableUserQueueSuffixResolver getUserQueueSuffixResolver()
public List<String> getSupportedProtocols()
SubProtocolHandler
null
.getSupportedProtocols
in interface SubProtocolHandler
public void handleMessageFromClient(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage webSocketMessage, MessageChannel outputChannel)
handleMessageFromClient
in interface SubProtocolHandler
session
- the client sessionwebSocketMessage
- the client messageoutputChannel
- an output channel to send messages toprotected void sendErrorMessage(org.springframework.web.socket.WebSocketSession session, Throwable error)
public void handleMessageToClient(org.springframework.web.socket.WebSocketSession session, Message<?> message)
handleMessageToClient
in interface SubProtocolHandler
session
- the client sessionmessage
- the client messagepublic String resolveSessionId(Message<?> message)
SubProtocolHandler
null
.resolveSessionId
in interface SubProtocolHandler
message
- the message to resolve the session id frompublic void afterSessionStarted(org.springframework.web.socket.WebSocketSession session, MessageChannel outputChannel)
SubProtocolHandler
WebSocketSession
has started.afterSessionStarted
in interface SubProtocolHandler
session
- the client sessionoutputChannel
- a channelpublic void afterSessionEnded(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus, MessageChannel outputChannel)
SubProtocolHandler
WebSocketSession
has ended.afterSessionEnded
in interface SubProtocolHandler
session
- the client sessioncloseStatus
- the reason why the session was closedoutputChannel
- a channel