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

public Class WebSocketSessionDecorator

extends Object
implements WebSocketSession
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.WebSocketSession, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator
Imports
java.io.IOException, java.net.InetSocketAddress, .URI, java.security.Principal, java.util.List, .Map, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.socket.CloseStatus, .WebSocketExtension, .WebSocketMessage, .WebSocketSession

Wraps another org.springframework.web.socket.WebSocketSession instance and delegates to it.

Also provides a getDelegate() method to return the decorated session as well as a getLastSession() method to go through all nested delegates and return the "last" session.

Author
Rossen Stoyanchev
Since
4.0.3

Field Summary

Modifier and TypeField and Description
private final WebSocketSession

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.springframework.web.socket.WebSocketSession.close.

Close the WebSocket connection with status 1000, i.e. equivalent to:

session.close(CloseStatus.NORMAL);
public void
close(CloseStatus status)

Implements org.springframework.web.socket.WebSocketSession.close.

Close the WebSocket connection with the given close status.

public String
public Map<String, Object>
getAttributes()

Implements org.springframework.web.socket.WebSocketSession.getAttributes.

Return the map with attributes associated with the WebSocket session.

public int
getBinaryMessageSizeLimit()

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

Get the configured maximum size for an incoming binary message.

public WebSocketSession
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 String
getId()

Implements org.springframework.web.socket.WebSocketSession.getId.

Return a unique session identifier.

public WebSocketSession
public InetSocketAddress
getLocalAddress()

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

Return the address on which the request was received.

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 boolean
isOpen()

Implements org.springframework.web.socket.WebSocketSession.isOpen.

Whether the underlying connection is open.

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.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public static WebSocketSession
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

delegateback to summary
private final WebSocketSession delegate

Constructor Detail

WebSocketSessionDecoratorback to summary
public WebSocketSessionDecorator(WebSocketSession session)

Method Detail

closeback to summary
public void close() throws IOException

Implements org.springframework.web.socket.WebSocketSession.close.

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

Close the WebSocket connection with status 1000, i.e. equivalent to:

session.close(CloseStatus.NORMAL);
Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

closeback to summary
public void close(CloseStatus status) throws IOException

Implements org.springframework.web.socket.WebSocketSession.close.

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

Close the WebSocket connection with the given close status.

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
getAttributesback to summary
public Map<String, Object> getAttributes()

Implements org.springframework.web.socket.WebSocketSession.getAttributes.

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

Return 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 via WebSocketClient handshake methods.

Returns:Map<String, Object>

a Map with the session attributes (never null)

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
getDelegateback to summary
public WebSocketSession getDelegate()
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
getIdback to summary
public String getId()

Implements org.springframework.web.socket.WebSocketSession.getId.

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

Return a unique session identifier.

Annotations
@Override
getLastSessionback to summary
public WebSocketSession getLastSession()
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
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
isOpenback to summary
public boolean isOpen()

Implements org.springframework.web.socket.WebSocketSession.isOpen.

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

Whether the underlying connection is open.

Annotations
@Override
sendMessageback to summary
public void sendMessage(WebSocketMessage<?> message) throws IOException

Implements org.springframework.web.socket.WebSocketSession.sendMessage.

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

Send a WebSocket message: either TextMessage or BinaryMessage.

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 WebSocketSession with the ConcurrentWebSocketSessionDecorator.

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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
unwrapback to summary
public static WebSocketSession unwrap(WebSocketSession session)