public interface SubProtocolHandler
WebSocketMessages
from a client
as well as Messages
to a client.
Implementations of this interface can be configured on a
SubProtocolWebSocketHandler
which selects a sub-protocol handler to
delegate messages to based on the sub-protocol requested by the client through
the Sec-WebSocket-Protocol
request header.
Modifier and Type | Method and Description |
---|---|
void |
afterSessionEnded(WebSocketSession session,
CloseStatus closeStatus,
MessageChannel outputChannel)
Invoked after a
WebSocketSession has ended. |
void |
afterSessionStarted(WebSocketSession session,
MessageChannel outputChannel)
Invoked after a
WebSocketSession has started. |
java.util.List<java.lang.String> |
getSupportedProtocols()
Return the list of sub-protocols supported by this handler (never
null ). |
void |
handleMessageFromClient(WebSocketSession session,
WebSocketMessage<?> message,
MessageChannel outputChannel)
Handle the given
WebSocketMessage received from a client. |
void |
handleMessageToClient(WebSocketSession session,
Message<?> message)
Handle the given
Message to the client associated with the given WebSocket session. |
java.lang.String |
resolveSessionId(Message<?> message)
Resolve the session id from the given message or return
null . |
java.util.List<java.lang.String> getSupportedProtocols()
null
).void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> message, MessageChannel outputChannel) throws java.lang.Exception
WebSocketMessage
received from a client.session
- the client sessionmessage
- the client messageoutputChannel
- an output channel to send messages tojava.lang.Exception
void handleMessageToClient(WebSocketSession session, Message<?> message) throws java.lang.Exception
Message
to the client associated with the given WebSocket session.session
- the client sessionmessage
- the client messagejava.lang.Exception
@Nullable java.lang.String resolveSessionId(Message<?> message)
null
.message
- the message to resolve the session id fromvoid afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) throws java.lang.Exception
WebSocketSession
has started.session
- the client sessionoutputChannel
- a channeljava.lang.Exception
void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) throws java.lang.Exception
WebSocketSession
has ended.session
- the client sessioncloseStatus
- the reason why the session was closedoutputChannel
- a channeljava.lang.Exception