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 ofAbstractClientSockJsSessionwrapping 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 Description WebSocketClientSockJsSession(TransportRequest request, WebSocketHandler handler, SettableListenableFuture<WebSocketSession> connectFuture)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddisconnect(CloseStatus status)StringgetAcceptedProtocol()Return the negotiated sub-protocol.intgetBinaryMessageSizeLimit()Get the configured maximum size for an incoming binary message.List<WebSocketExtension>getExtensions()Determine the negotiated extensions.InetSocketAddressgetLocalAddress()Return the address on which the request was received.ObjectgetNativeSession()Return the underlying native WebSocketSession.<T> TgetNativeSession(Class<T> requiredType)Return the underlying native WebSocketSession, if available.InetSocketAddressgetRemoteAddress()Return the address of the remote client.intgetTextMessageSizeLimit()Get the configured maximum size for an incoming text message.voidinitializeDelegateSession(WebSocketSession session)protected voidsendInternal(TextMessage textMessage)voidsetBinaryMessageSizeLimit(int messageSizeLimit)Configure the maximum size for an incoming binary message.voidsetTextMessageSizeLimit(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, SettableListenableFuture<WebSocketSession> connectFuture)
Method Detail
getNativeSession
public Object getNativeSession()
Description copied from interface:NativeWebSocketSessionReturn the underlying native WebSocketSession.- Specified by:
getNativeSessionin interfaceNativeWebSocketSession
getNativeSession
public <T> T getNativeSession(Class<T> requiredType)
Description copied from interface:NativeWebSocketSessionReturn the underlying native WebSocketSession, if available.- Specified by:
getNativeSessionin interfaceNativeWebSocketSession- Parameters:
requiredType- the required type of the session- Returns:
- the native session of the required type, or
nullif not available
getLocalAddress
public InetSocketAddress getLocalAddress()
Description copied from interface:WebSocketSessionReturn the address on which the request was received.- Specified by:
getLocalAddressin interfaceWebSocketSession
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:WebSocketSessionReturn the address of the remote client.- Specified by:
getRemoteAddressin interfaceWebSocketSession
getAcceptedProtocol
public String getAcceptedProtocol()
Description copied from interface:WebSocketSessionReturn the negotiated sub-protocol.- Specified by:
getAcceptedProtocolin interfaceWebSocketSession- Returns:
- the protocol identifier, or
nullif no protocol was specified or negotiated successfully
setTextMessageSizeLimit
public void setTextMessageSizeLimit(int messageSizeLimit)
Description copied from interface:WebSocketSessionConfigure the maximum size for an incoming text message.- Specified by:
setTextMessageSizeLimitin interfaceWebSocketSession
getTextMessageSizeLimit
public int getTextMessageSizeLimit()
Description copied from interface:WebSocketSessionGet the configured maximum size for an incoming text message.- Specified by:
getTextMessageSizeLimitin interfaceWebSocketSession
setBinaryMessageSizeLimit
public void setBinaryMessageSizeLimit(int messageSizeLimit)
Description copied from interface:WebSocketSessionConfigure the maximum size for an incoming binary message.- Specified by:
setBinaryMessageSizeLimitin interfaceWebSocketSession
getBinaryMessageSizeLimit
public int getBinaryMessageSizeLimit()
Description copied from interface:WebSocketSessionGet the configured maximum size for an incoming binary message.- Specified by:
getBinaryMessageSizeLimitin interfaceWebSocketSession
getExtensions
public List<WebSocketExtension> getExtensions()
Description copied from interface:WebSocketSessionDetermine the negotiated extensions.- Specified by:
getExtensionsin interfaceWebSocketSession- 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:
sendInternalin classAbstractClientSockJsSession- Throws:
IOException
disconnect
protected void disconnect(CloseStatus status) throws IOException
- Specified by:
disconnectin classAbstractClientSockJsSession- Throws:
IOException