Top Description Fields Constructors Methods
org.springframework.web.socket.sockjs.transport.handler

public Class SockJsWebSocketHandler

extends TextWebSocketHandler
implements SubProtocolCapable
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.SubProtocolCapable
Imports
java.util.ArrayList, .Collections, .List, java.util.concurrent.atomic.AtomicInteger, org.springframework.util.Assert, org.springframework.web.socket.CloseStatus, .SubProtocolCapable, .TextMessage, .WebSocketHandler, .WebSocketSession, org.springframework.web.socket.handler.TextWebSocketHandler, .WebSocketHandlerDecorator, org.springframework.web.socket.sockjs.transport.SockJsServiceConfig, org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession

An implementation of WebSocketHandler that adds SockJS messages frames, sends SockJS heartbeat messages, and delegates lifecycle events and messages to a target WebSocketHandler.

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 the handleTransportError method of the wrapped handler and the session closed.

Author
Rossen Stoyanchev
Since
4.0

Field Summary

Modifier and TypeField and Description
private final AtomicInteger
private final SockJsServiceConfig
private final WebSocketServerSockJsSession
private final List<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterConnectionClosed(WebSocketSession wsSession, CloseStatus status)

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.afterConnectionClosed.

Implements org.springframework.web.socket.WebSocketHandler.afterConnectionClosed.

Invoked after the WebSocket connection has been closed by either side, or after a transport error has occurred.

public void
afterConnectionEstablished(WebSocketSession wsSession)

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.afterConnectionEstablished.

Implements org.springframework.web.socket.WebSocketHandler.afterConnectionEstablished.

Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.

protected SockJsServiceConfig
public List<String>
getSubProtocols()

Implements org.springframework.web.socket.SubProtocolCapable.getSubProtocols.

Return the list of supported sub-protocols.

public void
public void
Inherited from org.springframework.web.socket.handler.TextWebSocketHandler:
handleBinaryMessage

Field Detail

sessionCountback to summary
private final AtomicInteger sessionCount
sockJsServiceConfigback to summary
private final SockJsServiceConfig sockJsServiceConfig
sockJsSessionback to summary
private final WebSocketServerSockJsSession sockJsSession
subProtocolsback to summary
private final List<String> subProtocols

Constructor Detail

SockJsWebSocketHandlerback to summary
public SockJsWebSocketHandler(SockJsServiceConfig serviceConfig, WebSocketHandler webSocketHandler, WebSocketServerSockJsSession sockJsSession)

Method Detail

afterConnectionClosedback to summary
public void afterConnectionClosed(WebSocketSession wsSession, CloseStatus status) throws Exception

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.afterConnectionClosed.

Implements org.springframework.web.socket.WebSocketHandler.afterConnectionClosed.

Doc from org.springframework.web.socket.WebSocketHandler.afterConnectionClosed.

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.

Annotations
@Override
Exceptions
Exception:
this method can handle or propagate exceptions; see class-level Javadoc for details.
afterConnectionEstablishedback to summary
public void afterConnectionEstablished(WebSocketSession wsSession) throws Exception

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.afterConnectionEstablished.

Implements org.springframework.web.socket.WebSocketHandler.afterConnectionEstablished.

Doc from org.springframework.web.socket.WebSocketHandler.afterConnectionEstablished.

Invoked after WebSocket negotiation has succeeded and the WebSocket connection is opened and ready for use.

Annotations
@Override
Exceptions
Exception:
this method can handle or propagate exceptions; see class-level Javadoc for details.
getSockJsConfigback to summary
protected SockJsServiceConfig getSockJsConfig()
getSubProtocolsback to summary
public List<String> getSubProtocols()

Implements org.springframework.web.socket.SubProtocolCapable.getSubProtocols.

Doc from org.springframework.web.socket.SubProtocolCapable.getSubProtocols.

Return the list of supported sub-protocols.

Annotations
@Override
handleTextMessageback to summary
public void handleTextMessage(WebSocketSession wsSession, TextMessage message) throws Exception

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.handleTextMessage.

Annotations
@Override
handleTransportErrorback to summary
public void handleTransportError(WebSocketSession webSocketSession, Throwable exception) throws Exception

Overrides org.springframework.web.socket.handler.AbstractWebSocketHandler.handleTransportError.

Implements org.springframework.web.socket.WebSocketHandler.handleTransportError.

Doc from org.springframework.web.socket.WebSocketHandler.handleTransportError.

Handle an error from the underlying WebSocket message transport.

Annotations
@Override
Exceptions
Exception:
this method can handle or propagate exceptions; see class-level Javadoc for details.