public interface SubProtocolHandler
WebSocketMessage
s from a client as well as Message
s 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. |
List<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. |
String |
resolveSessionId(Message<?> message)
Resolve the session id from the given message or return
null . |
List<String> getSupportedProtocols()
null
.void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> message, MessageChannel outputChannel) throws Exception
WebSocketMessage
received from a client.session
- the client sessionmessage
- the client messageoutputChannel
- an output channel to send messages toException
void handleMessageToClient(WebSocketSession session, Message<?> message) throws Exception
Message
to the client associated with the given WebSocket
session.session
- the client sessionmessage
- the client messageException
String resolveSessionId(Message<?> message)
null
.message
- the message to resolve the session id fromvoid afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) throws Exception
WebSocketSession
has started.session
- the client sessionoutputChannel
- a channelException
void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) throws Exception
WebSocketSession
has ended.session
- the client sessioncloseStatus
- the reason why the session was closedoutputChannel
- a channelException