接口 SubProtocolHandler
- 所有已知实现类:
StompSubProtocolHandler
public interface SubProtocolHandler
A contract for handling WebSocket messages as part of a higher level protocol, referred to as "sub-protocol" in the WebSocket RFC specification. Handles bothWebSocketMessages
from a client as well asMessages
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 theSec-WebSocket-Protocol
request header.- 从以下版本开始:
- 4.0
- 作者:
- Andy Wilkinson, Rossen Stoyanchev
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel)
Invoked after aWebSocketSession
has ended.void
afterSessionStarted(WebSocketSession session, MessageChannel outputChannel)
Invoked after aWebSocketSession
has started.List<String>
getSupportedProtocols()
Return the list of sub-protocols supported by this handler (nevernull
).void
handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> message, MessageChannel outputChannel)
Handle the givenWebSocketMessage
received from a client.void
handleMessageToClient(WebSocketSession session, Message<?> message)
Handle the givenMessage
to the client associated with the given WebSocket session.String
resolveSessionId(Message<?> message)
Resolve the session id from the given message or returnnull
.
方法详细资料
getSupportedProtocols
List<String> getSupportedProtocols()
Return the list of sub-protocols supported by this handler (nevernull
).
handleMessageFromClient
void handleMessageFromClient(WebSocketSession session, WebSocketMessage<?> message, MessageChannel outputChannel) throws Exception
Handle the givenWebSocketMessage
received from a client.- 参数:
session
- the client sessionmessage
- the client messageoutputChannel
- an output channel to send messages to- 抛出:
Exception
handleMessageToClient
void handleMessageToClient(WebSocketSession session, Message<?> message) throws Exception
Handle the givenMessage
to the client associated with the given WebSocket session.- 参数:
session
- the client sessionmessage
- the client message- 抛出:
Exception
resolveSessionId
@Nullable String resolveSessionId(Message<?> message)
Resolve the session id from the given message or returnnull
.- 参数:
message
- the message to resolve the session id from
afterSessionStarted
void afterSessionStarted(WebSocketSession session, MessageChannel outputChannel) throws Exception
Invoked after aWebSocketSession
has started.- 参数:
session
- the client sessionoutputChannel
- a channel- 抛出:
Exception
afterSessionEnded
void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) throws Exception
Invoked after aWebSocketSession
has ended.- 参数:
session
- the client sessioncloseStatus
- the reason why the session was closedoutputChannel
- a channel- 抛出:
Exception