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.
Modifier and Type | Field and Description |
---|---|
private WebSocketSession |
delegate |
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 or
null if none was specified or
negotiated successfully. |
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()
Return the negotiated extensions or
null if none was specified or
negotiated successfully. |
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request.
|
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) |
private final WebSocketSession delegate
public WebSocketSessionDecorator(WebSocketSession session)
public WebSocketSession getDelegate()
public WebSocketSession getLastSession()
public static WebSocketSession unwrap(WebSocketSession session)
public java.lang.String getId()
WebSocketSession
getId
in interface WebSocketSession
public java.net.URI getUri()
WebSocketSession
getUri
in interface WebSocketSession
public HttpHeaders getHandshakeHeaders()
WebSocketSession
getHandshakeHeaders
in interface WebSocketSession
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
WebSocketSession
When the WebSocketSession is created, on the server side, the map can be
through a HandshakeInterceptor
.
On the client side, the map can be populated by passing attributes to the
WebSocketClient
handshake
methods.
getAttributes
in interface WebSocketSession
public java.security.Principal getPrincipal()
WebSocketSession
Principal
instance containing the name of the
authenticated user. If the user has not been authenticated, the method returns
null
.getPrincipal
in interface WebSocketSession
public java.net.InetSocketAddress getLocalAddress()
WebSocketSession
getLocalAddress
in interface WebSocketSession
public java.net.InetSocketAddress getRemoteAddress()
WebSocketSession
getRemoteAddress
in interface WebSocketSession
public java.lang.String getAcceptedProtocol()
WebSocketSession
null
if none was specified or
negotiated successfully.getAcceptedProtocol
in interface WebSocketSession
public java.util.List<WebSocketExtension> getExtensions()
WebSocketSession
null
if none was specified or
negotiated successfully.getExtensions
in interface WebSocketSession
public void setTextMessageSizeLimit(int messageSizeLimit)
WebSocketSession
setTextMessageSizeLimit
in interface WebSocketSession
public int getTextMessageSizeLimit()
WebSocketSession
getTextMessageSizeLimit
in interface WebSocketSession
public void setBinaryMessageSizeLimit(int messageSizeLimit)
WebSocketSession
setBinaryMessageSizeLimit
in interface WebSocketSession
public int getBinaryMessageSizeLimit()
WebSocketSession
getBinaryMessageSizeLimit
in interface WebSocketSession
public boolean isOpen()
WebSocketSession
isOpen
in interface WebSocketSession
public void sendMessage(WebSocketMessage<?> message) throws java.io.IOException
WebSocketSession
TextMessage
or
BinaryMessage
.sendMessage
in interface WebSocketSession
java.io.IOException
public void close() throws java.io.IOException
WebSocketSession
session.close(CloseStatus.NORMAL);
close
in interface WebSocketSession
java.io.IOException
public void close(CloseStatus status) throws java.io.IOException
WebSocketSession
close
in interface WebSocketSession
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object