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()
WebSocketSession
getId
in interface WebSocketSession
public java.net.URI getUri()
WebSocketSession
getUri
in interface WebSocketSession
public HttpHeaders getHandshakeHeaders()
WebSocketSession
null
).getHandshakeHeaders
in interface WebSocketSession
public java.util.Map<java.lang.String,java.lang.Object> getAttributes()
WebSocketSession
On 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 WebSocketSession
null
)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
getAcceptedProtocol
in interface WebSocketSession
null
if no protocol
was specified or negotiated successfullypublic java.util.List<WebSocketExtension> getExtensions()
WebSocketSession
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 java.io.Closeable
close
in interface java.lang.AutoCloseable
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