类 SockJsWebSocketHandler
- java.lang.Object
- org.springframework.web.socket.handler.AbstractWebSocketHandler
- org.springframework.web.socket.handler.TextWebSocketHandler
- org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler
- 所有已实现的接口:
SubProtocolCapable
,WebSocketHandler
public class SockJsWebSocketHandler extends TextWebSocketHandler implements SubProtocolCapable
An implementation ofWebSocketHandler
that adds SockJS messages frames, sends SockJS heartbeat messages, and delegates lifecycle events and messages to a targetWebSocketHandler
.Methods in this class allow exceptions from the wrapped
WebSocketHandler
to propagate. However, any exceptions resulting from SockJS message handling (e.g. while sending SockJS frames or heartbeat messages) are caught and treated as transport errors, i.e. routed to thehandleTransportError
method of the wrapped handler and the session closed.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession sockJsSession)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterConnectionClosed(WebSocketSession wsSession, CloseStatus status)
Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.void
afterConnectionEstablished(WebSocketSession wsSession)
Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.protected SockJsServiceConfig
getSockJsConfig()
List<String>
getSubProtocols()
Return the list of supported sub-protocols.void
handleTextMessage(WebSocketSession wsSession, TextMessage message)
void
handleTransportError(WebSocketSession webSocketSession, Throwable exception)
Handle an error from the underlying WebSocket message transport.从类继承的方法 org.springframework.web.socket.handler.TextWebSocketHandler
handleBinaryMessage
从类继承的方法 org.springframework.web.socket.handler.AbstractWebSocketHandler
handleMessage, handlePongMessage, supportsPartialMessages
构造器详细资料
SockJsWebSocketHandler
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession sockJsSession)
方法详细资料
getSubProtocols
public List<String> getSubProtocols()
从接口复制的说明:SubProtocolCapable
Return the list of supported sub-protocols.- 指定者:
getSubProtocols
在接口中SubProtocolCapable
getSockJsConfig
protected SockJsServiceConfig getSockJsConfig()
afterConnectionEstablished
public void afterConnectionEstablished(WebSocketSession wsSession) throws Exception
从接口复制的说明:WebSocketHandler
Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.- 指定者:
afterConnectionEstablished
在接口中WebSocketHandler
- 覆盖:
afterConnectionEstablished
在类中AbstractWebSocketHandler
- 抛出:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
handleTextMessage
public void handleTextMessage(WebSocketSession wsSession, TextMessage message) throws Exception
afterConnectionClosed
public void afterConnectionClosed(WebSocketSession wsSession, CloseStatus status) throws Exception
从接口复制的说明:WebSocketHandler
Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred. Although the session may technically still be open, depending on the underlying implementation, sending messages at this point is discouraged and most likely will not succeed.- 指定者:
afterConnectionClosed
在接口中WebSocketHandler
- 覆盖:
afterConnectionClosed
在类中AbstractWebSocketHandler
- 抛出:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.
handleTransportError
public void handleTransportError(WebSocketSession webSocketSession, Throwable exception) throws Exception
从接口复制的说明:WebSocketHandler
Handle an error from the underlying WebSocket message transport.- 指定者:
handleTransportError
在接口中WebSocketHandler
- 覆盖:
handleTransportError
在类中AbstractWebSocketHandler
- 抛出:
Exception
- this method can handle or propagate exceptions; see class-level Javadoc for details.