org.springframework.web.socket.sockjs.client

## Class WebSocketClientSockJsSession

- java.lang.Object
- - org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession
  - - org.springframework.web.socket.sockjs.client.WebSocketClientSockJsSession

All Implemented Interfaces:
  Closeable, AutoCloseable, NativeWebSocketSession, WebSocketSession

    public class WebSocketClientSockJsSession
    extends AbstractClientSockJsSession
    implements NativeWebSocketSession

An extension of `AbstractClientSockJsSession` wrapping and delegating to an actual WebSocket session.

Since:
  4.1
Author:
  Rossen Stoyanchev

### Field Summary

### Fields inherited from class org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession

`logger`

### Constructor Summary

Constructors
Constructor and Description
`WebSocketClientSockJsSession(TransportRequest request, WebSocketHandler handler, org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `disconnect(CloseStatus status)`
`String` `getAcceptedProtocol()` Return the negotiated sub-protocol.
`int` `getBinaryMessageSizeLimit()` Get the configured maximum size for an incoming binary message.
`List<WebSocketExtension>` `getExtensions()` Determine the negotiated extensions.
`InetSocketAddress` `getLocalAddress()` Return the address on which the request was received.
`Object` `getNativeSession()` Return the underlying native WebSocketSession.
`<T> T` `getNativeSession(Class<T> requiredType)` Return the underlying native WebSocketSession, if available.
`InetSocketAddress` `getRemoteAddress()` Return the address of the remote client.
`int` `getTextMessageSizeLimit()` Get the configured maximum size for an incoming text message.
`void` `initializeDelegateSession(WebSocketSession session)`
`protected void` `sendInternal(TextMessage textMessage)`
`void` `setBinaryMessageSizeLimit(int messageSizeLimit)` Configure the maximum size for an incoming binary message.
`void` `setTextMessageSizeLimit(int messageSizeLimit)` Configure the maximum size for an incoming text message.

### Methods inherited from class org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession

`afterTransportClosed, close, close, closeInternal, getAttributes, getHandshakeHeaders, getId, getMessageCodec, getPrincipal, getUri, getWebSocketHandler, handleFrame, handleTransportError, isDisconnected, isOpen, sendMessage, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.web.socket.WebSocketSession

`close, close, getAttributes, getHandshakeHeaders, getId, getPrincipal, getUri, isOpen, sendMessage`

### Constructor Detail

#### WebSocketClientSockJsSession

    public WebSocketClientSockJsSession(TransportRequest request,
                                        WebSocketHandler handler,
                                        org.springframework.util.concurrent.SettableListenableFuture<WebSocketSession> connectFuture)

### Method Detail

#### getNativeSession

    public Object getNativeSession()

Description copied from interface: `NativeWebSocketSession`
Return the underlying native WebSocketSession.

Specified by:
  `getNativeSession` in interface `NativeWebSocketSession`

#### getNativeSession

    @Nullable
    public <T> T getNativeSession(@Nullable
                                            Class<T> requiredType)

Description copied from interface: `NativeWebSocketSession`
Return the underlying native WebSocketSession, if available.

Specified by:
  `getNativeSession` in interface `NativeWebSocketSession`
Parameters:
  `requiredType` - the required type of the session
Returns:
  the native session of the required type, or `null` if not available

#### getLocalAddress

    public InetSocketAddress getLocalAddress()

Description copied from interface: `WebSocketSession`
Return the address on which the request was received.

Specified by:
  `getLocalAddress` in interface `WebSocketSession`

#### getRemoteAddress

    public InetSocketAddress getRemoteAddress()

Description copied from interface: `WebSocketSession`
Return the address of the remote client.

Specified by:
  `getRemoteAddress` in interface `WebSocketSession`

#### getAcceptedProtocol

    public String getAcceptedProtocol()

Description copied from interface: `WebSocketSession`
Return the negotiated sub-protocol.

Specified by:
  `getAcceptedProtocol` in interface `WebSocketSession`
Returns:
  the protocol identifier, or `null` if no protocol was specified or negotiated successfully

#### setTextMessageSizeLimit

    public void setTextMessageSizeLimit(int messageSizeLimit)

Description copied from interface: `WebSocketSession`
Configure the maximum size for an incoming text message.

Specified by:
  `setTextMessageSizeLimit` in interface `WebSocketSession`

#### getTextMessageSizeLimit

    public int getTextMessageSizeLimit()

Description copied from interface: `WebSocketSession`
Get the configured maximum size for an incoming text message.

Specified by:
  `getTextMessageSizeLimit` in interface `WebSocketSession`

#### setBinaryMessageSizeLimit

    public void setBinaryMessageSizeLimit(int messageSizeLimit)

Description copied from interface: `WebSocketSession`
Configure the maximum size for an incoming binary message.

Specified by:
  `setBinaryMessageSizeLimit` in interface `WebSocketSession`

#### getBinaryMessageSizeLimit

    public int getBinaryMessageSizeLimit()

Description copied from interface: `WebSocketSession`
Get the configured maximum size for an incoming binary message.

Specified by:
  `getBinaryMessageSizeLimit` in interface `WebSocketSession`

#### getExtensions

    public List<WebSocketExtension> getExtensions()

Description copied from interface: `WebSocketSession`
Determine the negotiated extensions.

Specified by:
  `getExtensions` in interface `WebSocketSession`
Returns:
  the list of extensions, or an empty list if no extension was specified or negotiated successfully

#### initializeDelegateSession

    public void initializeDelegateSession(WebSocketSession session)

#### sendInternal

    protected void sendInternal(TextMessage textMessage)
                         throws IOException

Specified by:
  `sendInternal` in class `AbstractClientSockJsSession`
Throws:
  `IOException`

#### disconnect

    protected void disconnect(CloseStatus status)
                       throws IOException

Specified by:
  `disconnect` in class `AbstractClientSockJsSession`
Throws:
  `IOException`