Class AbstractClientSockJsSession
java.lang.Object
org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession
- All Implemented Interfaces:
- Closeable, AutoCloseable, WebSocketSession
- Direct Known Subclasses:
- WebSocketClientSockJsSession, XhrClientSockJsSession
Base class for SockJS client implementations of 
WebSocketSession.
Provides processing of incoming SockJS message frames and delegates lifecycle
events and messages to the (application) WebSocketHandler.
Subclasses implement actual send as well as disconnect logic.
- Since:
- 4.1
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler, CompletableFuture<WebSocketSession> connectFuture) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidafterTransportClosed(@Nullable CloseStatus closeStatus) final voidclose()Close the WebSocket connection with status 1000, i.e.final voidclose(CloseStatus status) Close the WebSocket connection with the given close status.protected voidcloseInternal(CloseStatus status) protected abstract voiddisconnect(CloseStatus status) Return the map with attributes associated with the WebSocket session.Return the headers used in the handshake request (nevernull).getId()Return a unique session identifier.Return aPrincipalinstance containing the name of the authenticated user.getUri()Return the URI used to open the WebSocket connection.voidhandleFrame(String payload) voidhandleTransportError(Throwable error) booleanbooleanisOpen()Whether the underlying connection is open.protected abstract voidsendInternal(TextMessage textMessage) final voidsendMessage(WebSocketMessage<?> message) Send a WebSocket message: eitherTextMessageorBinaryMessage.toString()Methods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface WebSocketSessiongetAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getLocalAddress, getRemoteAddress, getTextMessageSizeLimit, setBinaryMessageSizeLimit, setTextMessageSizeLimit
- 
Field Details- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
AbstractClientSockJsSessionprotected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler, CompletableFuture<WebSocketSession> connectFuture) 
 
- 
- 
Method Details- 
getIdDescription copied from interface:WebSocketSessionReturn a unique session identifier.- Specified by:
- getIdin interface- WebSocketSession
 
- 
getUriDescription copied from interface:WebSocketSessionReturn the URI used to open the WebSocket connection.- Specified by:
- getUriin interface- WebSocketSession
 
- 
getHandshakeHeadersDescription copied from interface:WebSocketSessionReturn the headers used in the handshake request (nevernull).- Specified by:
- getHandshakeHeadersin interface- WebSocketSession
 
- 
getAttributesDescription copied from interface:WebSocketSessionReturn the map with attributes associated with the WebSocket session.On the server side the map can be populated initially through a HandshakeInterceptor. On the client side the map can be populated viaWebSocketClienthandshake methods.- Specified by:
- getAttributesin interface- WebSocketSession
- Returns:
- a Map with the session attributes (never null)
 
- 
getPrincipalDescription copied from interface:WebSocketSessionReturn aPrincipalinstance containing the name of the authenticated user.If the user has not been authenticated, the method returns null.- Specified by:
- getPrincipalin interface- WebSocketSession
 
- 
getMessageCodec
- 
getWebSocketHandler
- 
isOpenpublic boolean isOpen()Description copied from interface:WebSocketSessionWhether the underlying connection is open.- Specified by:
- isOpenin interface- WebSocketSession
 
- 
isDisconnectedpublic boolean isDisconnected()
- 
sendMessageDescription copied from interface:WebSocketSessionSend a WebSocket message: eitherTextMessageorBinaryMessage.Note: The underlying standard WebSocket session (JSR-356) does not allow concurrent sending. Therefore, sending must be synchronized. To ensure that, one option is to wrap the WebSocketSessionwith theConcurrentWebSocketSessionDecorator.- Specified by:
- sendMessagein interface- WebSocketSession
- Throws:
- IOException
- See Also:
 
- 
sendInternal- Throws:
- IOException
 
- 
closeDescription copied from interface:WebSocketSessionClose the WebSocket connection with status 1000, i.e. equivalent to:session.close(CloseStatus.NORMAL); - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- WebSocketSession
- Throws:
- IOException
 
- 
closeDescription copied from interface:WebSocketSessionClose the WebSocket connection with the given close status.- Specified by:
- closein interface- WebSocketSession
- Throws:
- IOException
 
- 
closeInternal- Throws:
- IOException
 
- 
disconnect- Throws:
- IOException
 
- 
handleFrame
- 
handleTransportError
- 
afterTransportClosed
- 
toString
 
-