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

public Class WebSocketServerSockJsSession

extends AbstractSockJsSession
implements NativeWebSocketSession
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.adapter.NativeWebSocketSession, org.springframework.web.socket.WebSocketSession, java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.IOException, java.net.InetSocketAddress, .URI, java.security.Principal, java.util.List, .Map, .Queue, java.util.concurrent.LinkedBlockingDeque, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils, org.springframework.web.socket.CloseStatus, .TextMessage, .WebSocketExtension, .WebSocketHandler, .WebSocketSession, org.springframework.web.socket.adapter.NativeWebSocketSession, org.springframework.web.socket.sockjs.SockJsTransportFailureException, org.springframework.web.socket.sockjs.frame.SockJsFrame, org.springframework.web.socket.sockjs.transport.SockJsServiceConfig

A SockJS session for use with the WebSocket transport.
Authors
Rossen Stoyanchev, Juergen Hoeller
Since
4.0

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final Object
private final Queue<String>
private final Object
private volatile boolean
private WebSocketSession
Inherited from org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession:
DISCONNECTED_CLIENT_LOG_CATEGORYloggerresponseLock

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
disconnect(CloseStatus status)

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.disconnect.

Actually close the underlying WebSocket session or in the case of HTTP transports complete the underlying request.

public String
public int
getBinaryMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Get the configured maximum size for an incoming binary message.

public List<WebSocketExtension>
getExtensions()

Implements org.springframework.web.socket.WebSocketSession.getExtensions.

Determine the negotiated extensions.

public HttpHeaders
getHandshakeHeaders()

Implements org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Return the headers used in the handshake request (never null).

public InetSocketAddress
getLocalAddress()

Implements org.springframework.web.socket.WebSocketSession.getLocalAddress.

Return the address on which the request was received.

public Object
public <T> T
getNativeSession(Class<T>
the required type of the session
requiredType
)

Implements org.springframework.web.socket.adapter.NativeWebSocketSession.getNativeSession.

Return the underlying native WebSocketSession, if available.

public Principal
getPrincipal()

Implements org.springframework.web.socket.WebSocketSession.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.

public InetSocketAddress
getRemoteAddress()

Implements org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Return the address of the remote client.

public int
getTextMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Get the configured maximum size for an incoming text message.

public URI
getUri()

Implements org.springframework.web.socket.WebSocketSession.getUri.

Return the URI used to open the WebSocket connection.

public void
public void
public boolean
isActive()

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.isActive.

Polling and Streaming sessions periodically close the current HTTP request and wait for the next request to come through.

public void
public void
setBinaryMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Configure the maximum size for an incoming binary message.

public void
setTextMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Configure the maximum size for an incoming text message.

protected void
Inherited from org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession:
cancelHeartbeatcloseclosedelegateConnectionCloseddelegateConnectionEstablisheddelegateErrordelegateMessagesdisableHeartbeatgetAttributesgetIdgetMessageCodecgetSockJsServiceConfiggetTimeSinceLastActiveisClosedisNewisOpenscheduleHeartbeatsendHeartbeatsendMessagetoStringtryCloseWithSockJsTransportErrorupdateLastActiveTimewriteFrame

Field Detail

disconnectedback to summary
private volatile boolean disconnected
disconnectLockback to summary
private final Object disconnectLock
initSessionCacheback to summary
private final Queue<String> initSessionCache
initSessionLockback to summary
private final Object initSessionLock
openFrameSentback to summary
private volatile boolean openFrameSent
webSocketSessionback to summary
private WebSocketSession webSocketSession
Annotations
@Nullable

Constructor Detail

WebSocketServerSockJsSessionback to summary
public WebSocketServerSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler, Map<String, Object> attributes)

Method Detail

disconnectback to summary
protected void disconnect(CloseStatus status) throws IOException

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.disconnect.

Doc from org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.disconnect.

Actually close the underlying WebSocket session or in the case of HTTP transports complete the underlying request.

Annotations
@Override
getAcceptedProtocolback to summary
public String getAcceptedProtocol()

Implements org.springframework.web.socket.WebSocketSession.getAcceptedProtocol.

Doc from org.springframework.web.socket.WebSocketSession.getAcceptedProtocol.

Return the negotiated sub-protocol.

Returns:String

the protocol identifier, or null if no protocol was specified or negotiated successfully

Annotations
@Override
getBinaryMessageSizeLimitback to summary
public int getBinaryMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Get the configured maximum size for an incoming binary message.

Annotations
@Override
getExtensionsback to summary
public List<WebSocketExtension> getExtensions()

Implements org.springframework.web.socket.WebSocketSession.getExtensions.

Doc from org.springframework.web.socket.WebSocketSession.getExtensions.

Determine the negotiated extensions.

Returns:List<WebSocketExtension>

the list of extensions, or an empty list if no extension was specified or negotiated successfully

Annotations
@Override
getHandshakeHeadersback to summary
public HttpHeaders getHandshakeHeaders()

Implements org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Doc from org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Return the headers used in the handshake request (never null).

Annotations
@Override
getLocalAddressback to summary
public InetSocketAddress getLocalAddress()

Implements org.springframework.web.socket.WebSocketSession.getLocalAddress.

Doc from org.springframework.web.socket.WebSocketSession.getLocalAddress.

Return the address on which the request was received.

Annotations
@Override
getNativeSessionback to summary
public Object getNativeSession()

Implements org.springframework.web.socket.adapter.NativeWebSocketSession.getNativeSession.

Doc from org.springframework.web.socket.adapter.NativeWebSocketSession.getNativeSession.

Return the underlying native WebSocketSession.

Annotations
@Override
getNativeSessionback to summary
public <T> T getNativeSession(Class<T> requiredType)

Implements org.springframework.web.socket.adapter.NativeWebSocketSession.getNativeSession.

Doc from org.springframework.web.socket.adapter.NativeWebSocketSession.getNativeSession.

Return the underlying native WebSocketSession, if available.

Parameters
requiredType:Class<T>

the required type of the session

Returns:T

the native session of the required type, or null if not available

Annotations
@Override
@Nullable
getPrincipalback to summary
public Principal getPrincipal()

Implements org.springframework.web.socket.WebSocketSession.getPrincipal.

Doc from org.springframework.web.socket.WebSocketSession.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.

If the user has not been authenticated, the method returns null.

Annotations
@Override
getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()

Implements org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Doc from org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Return the address of the remote client.

Annotations
@Override
getTextMessageSizeLimitback to summary
public int getTextMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Get the configured maximum size for an incoming text message.

Annotations
@Override
getUriback to summary
public URI getUri()

Implements org.springframework.web.socket.WebSocketSession.getUri.

Doc from org.springframework.web.socket.WebSocketSession.getUri.

Return the URI used to open the WebSocket connection.

Annotations
@Override
@Nullable
handleMessageback to summary
public void handleMessage(TextMessage message, WebSocketSession wsSession) throws Exception
initializeDelegateSessionback to summary
public void initializeDelegateSession(WebSocketSession session)
isActiveback to summary
public boolean isActive()

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.isActive.

Doc from org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.isActive.

Polling and Streaming sessions periodically close the current HTTP request and wait for the next request to come through. During this "downtime" the session is still open but inactive and unable to send messages and therefore has to buffer them temporarily. A WebSocket session by contrast is stateful and remain active until closed.

Annotations
@Override
sendMessageInternalback to summary
public void sendMessageInternal(String message) throws SockJsTransportFailureException

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendMessageInternal.

Annotations
@Override
setBinaryMessageSizeLimitback to summary
public void setBinaryMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Configure the maximum size for an incoming binary message.

Annotations
@Override
setTextMessageSizeLimitback to summary
public void setTextMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Configure the maximum size for an incoming text message.

Annotations
@Override
writeFrameInternalback to summary
protected void writeFrameInternal(SockJsFrame frame) throws IOException

Implements abstract org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrameInternal.

Annotations
@Override