Class StandardWebSocketSession
java.lang.Object
org.springframework.web.socket.adapter.AbstractWebSocketSession<Session>
org.springframework.web.socket.adapter.standard.StandardWebSocketSession
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- NativeWebSocketSession,- WebSocketSession
A 
WebSocketSession for use with the standard WebSocket for Java API.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- 
Field SummaryFields inherited from class org.springframework.web.socket.adapter.AbstractWebSocketSessionidGenerator, logger
- 
Constructor SummaryConstructorsConstructorDescriptionStandardWebSocketSession(HttpHeaders headers, Map<String, Object> attributes, InetSocketAddress localAddress, InetSocketAddress remoteAddress) Constructor for a standard WebSocket session.StandardWebSocketSession(HttpHeaders headers, Map<String, Object> attributes, InetSocketAddress localAddress, InetSocketAddress remoteAddress, Principal user) Constructor that associates a user with the WebSocket session.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcloseInternal(CloseStatus status) Return the negotiated sub-protocol.intGet the configured maximum size for an incoming binary message.Determine the negotiated extensions.Return the headers used in the handshake request (nevernull).getId()Return a unique session identifier.Return the address on which the request was received.Return aPrincipalinstance containing the name of the authenticated user.Return the address of the remote client.intGet the configured maximum size for an incoming text message.getUri()Return the URI used to open the WebSocket connection.voidinitializeNativeSession(Session session) booleanisOpen()Whether the underlying connection is open.protected voidsendBinaryMessage(BinaryMessage message) protected voidsendPingMessage(PingMessage message) protected voidsendPongMessage(PongMessage message) protected voidsendTextMessage(TextMessage message) 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.adapter.AbstractWebSocketSessioncheckNativeSessionInitialized, close, close, getAttributes, getNativeSession, getNativeSession, sendMessage, toString
- 
Constructor Details- 
StandardWebSocketSessionpublic StandardWebSocketSession(@Nullable HttpHeaders headers, @Nullable Map<String, Object> attributes, @Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress) Constructor for a standard WebSocket session.- Parameters:
- headers- the headers of the handshake request
- attributes- the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.
- localAddress- the address on which the request was received
- remoteAddress- the address of the remote client
 
- 
StandardWebSocketSessionpublic StandardWebSocketSession(@Nullable HttpHeaders headers, @Nullable Map<String, Object> attributes, @Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress, @Nullable Principal user) Constructor that associates a user with the WebSocket session.- Parameters:
- headers- the headers of the handshake request
- attributes- the attributes from the HTTP handshake to associate with the WebSocket session
- localAddress- the address on which the request was received
- remoteAddress- the address of the remote client
- user- the user associated with the session; if- nullwe'll fall back on the user available in the underlying WebSocket session
 
 
- 
- 
Method Details- 
getIdDescription copied from interface:WebSocketSessionReturn a unique session identifier.
- 
getUriDescription copied from interface:WebSocketSessionReturn the URI used to open the WebSocket connection.
- 
getHandshakeHeadersDescription copied from interface:WebSocketSessionReturn the headers used in the handshake request (nevernull).
- 
getAcceptedProtocolDescription copied from interface:WebSocketSessionReturn the negotiated sub-protocol.- Returns:
- the protocol identifier, or nullif no protocol was specified or negotiated successfully
 
- 
getExtensionsDescription copied from interface:WebSocketSessionDetermine the negotiated extensions.- Returns:
- the list of extensions, or an empty list if no extension was specified or negotiated successfully
 
- 
getPrincipalDescription copied from interface:WebSocketSessionReturn aPrincipalinstance containing the name of the authenticated user.If the user has not been authenticated, the method returns null.
- 
getLocalAddressDescription copied from interface:WebSocketSessionReturn the address on which the request was received.
- 
getRemoteAddressDescription copied from interface:WebSocketSessionReturn the address of the remote client.
- 
setTextMessageSizeLimitpublic void setTextMessageSizeLimit(int messageSizeLimit) Description copied from interface:WebSocketSessionConfigure the maximum size for an incoming text message.
- 
getTextMessageSizeLimitpublic int getTextMessageSizeLimit()Description copied from interface:WebSocketSessionGet the configured maximum size for an incoming text message.
- 
setBinaryMessageSizeLimitpublic void setBinaryMessageSizeLimit(int messageSizeLimit) Description copied from interface:WebSocketSessionConfigure the maximum size for an incoming binary message.
- 
getBinaryMessageSizeLimitpublic int getBinaryMessageSizeLimit()Description copied from interface:WebSocketSessionGet the configured maximum size for an incoming binary message.
- 
isOpenpublic boolean isOpen()Description copied from interface:WebSocketSessionWhether the underlying connection is open.
- 
initializeNativeSession- Overrides:
- initializeNativeSessionin class- AbstractWebSocketSession<Session>
 
- 
sendTextMessage- Specified by:
- sendTextMessagein class- AbstractWebSocketSession<Session>
- Throws:
- IOException
 
- 
sendBinaryMessage- Specified by:
- sendBinaryMessagein class- AbstractWebSocketSession<Session>
- Throws:
- IOException
 
- 
sendPingMessage- Specified by:
- sendPingMessagein class- AbstractWebSocketSession<Session>
- Throws:
- IOException
 
- 
sendPongMessage- Specified by:
- sendPongMessagein class- AbstractWebSocketSession<Session>
- Throws:
- IOException
 
- 
closeInternal- Specified by:
- closeInternalin class- AbstractWebSocketSession<Session>
- Throws:
- IOException
 
 
-