public class WebSocketSessionDecorator extends java.lang.Object implements WebSocketSession
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.
| Constructor and Description |
|---|
WebSocketSessionDecorator(WebSocketSession session) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the WebSocket connection with status 1000, i.e.
|
void |
close(CloseStatus status)
Close the WebSocket connection with the given close status.
|
java.lang.String |
getAcceptedProtocol()
Return the negotiated sub-protocol.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Return the map with attributes associated with the WebSocket session.
|
int |
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.
|
WebSocketSession |
getDelegate() |
java.util.List<WebSocketExtension> |
getExtensions()
Determine the negotiated extensions.
|
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request (never
null). |
java.lang.String |
getId()
Return a unique session identifier.
|
WebSocketSession |
getLastSession() |
java.net.InetSocketAddress |
getLocalAddress()
Return the address on which the request was received.
|
java.security.Principal |
getPrincipal()
Return a
Principal instance containing the name
of the authenticated user. |
java.net.InetSocketAddress |
getRemoteAddress()
Return the address of the remote client.
|
int |
getTextMessageSizeLimit()
Get the configured maximum size for an incoming text message.
|
java.net.URI |
getUri()
Return the URI used to open the WebSocket connection.
|
boolean |
isOpen()
Return whether the connection is still open.
|
void |
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message: either
TextMessage or BinaryMessage. |
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.
|
java.lang.String |
toString() |
static WebSocketSession |
unwrap(WebSocketSession session) |
public WebSocketSessionDecorator(WebSocketSession session)
public WebSocketSession getDelegate()
public WebSocketSession getLastSession()
public static WebSocketSession unwrap(WebSocketSession session)
public java.lang.String getId()
WebSocketSessiongetId in interface WebSocketSession@Nullable public java.net.URI getUri()
WebSocketSessiongetUri in interface WebSocketSessionpublic HttpHeaders getHandshakeHeaders()
WebSocketSessionnull).getHandshakeHeaders in interface WebSocketSessionpublic java.util.Map<java.lang.String,java.lang.Object> getAttributes()
WebSocketSessionOn 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.
getAttributes in interface WebSocketSessionnull)public java.security.Principal getPrincipal()
WebSocketSessionPrincipal instance containing the name
of the authenticated user.
If the user has not been authenticated, the method returns null.
getPrincipal in interface WebSocketSessionpublic java.net.InetSocketAddress getLocalAddress()
WebSocketSessiongetLocalAddress in interface WebSocketSessionpublic java.net.InetSocketAddress getRemoteAddress()
WebSocketSessiongetRemoteAddress in interface WebSocketSessionpublic java.lang.String getAcceptedProtocol()
WebSocketSessiongetAcceptedProtocol in interface WebSocketSessionnull if no protocol
was specified or negotiated successfullypublic java.util.List<WebSocketExtension> getExtensions()
WebSocketSessiongetExtensions in interface WebSocketSessionpublic void setTextMessageSizeLimit(int messageSizeLimit)
WebSocketSessionsetTextMessageSizeLimit in interface WebSocketSessionpublic int getTextMessageSizeLimit()
WebSocketSessiongetTextMessageSizeLimit in interface WebSocketSessionpublic void setBinaryMessageSizeLimit(int messageSizeLimit)
WebSocketSessionsetBinaryMessageSizeLimit in interface WebSocketSessionpublic int getBinaryMessageSizeLimit()
WebSocketSessiongetBinaryMessageSizeLimit in interface WebSocketSessionpublic boolean isOpen()
WebSocketSessionisOpen in interface WebSocketSessionpublic void sendMessage(WebSocketMessage<?> message) throws java.io.IOException
WebSocketSessionTextMessage or BinaryMessage.sendMessage in interface WebSocketSessionjava.io.IOExceptionpublic void close()
throws java.io.IOException
WebSocketSessionsession.close(CloseStatus.NORMAL);
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface WebSocketSessionjava.io.IOExceptionpublic void close(CloseStatus status) throws java.io.IOException
WebSocketSessionclose in interface WebSocketSessionjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object