public class WebSocketSessionDecorator extends 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.
|
String |
getAcceptedProtocol()
Return the negotiated sub-protocol or
null if none was specified or
negotiated successfully. |
Map<String,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() |
List<WebSocketExtension> |
getExtensions()
Return the negotiated extensions or
null if none was specified or
negotiated successfully. |
org.springframework.http.HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request.
|
String |
getId()
Return a unique session identifier.
|
WebSocketSession |
getLastSession() |
InetSocketAddress |
getLocalAddress()
Return the address on which the request was received.
|
Principal |
getPrincipal()
Return a
Principal instance containing the name of the
authenticated user. |
InetSocketAddress |
getRemoteAddress()
Return the address of the remote client.
|
int |
getTextMessageSizeLimit()
Get the configured maximum size for an incoming text message.
|
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.
|
String |
toString() |
static WebSocketSession |
unwrap(WebSocketSession session) |
public WebSocketSessionDecorator(WebSocketSession session)
public WebSocketSession getDelegate()
public WebSocketSession getLastSession()
public static WebSocketSession unwrap(WebSocketSession session)
public String getId()
WebSocketSessiongetId in interface WebSocketSessionpublic URI getUri()
WebSocketSessiongetUri in interface WebSocketSessionpublic org.springframework.http.HttpHeaders getHandshakeHeaders()
WebSocketSessiongetHandshakeHeaders in interface WebSocketSessionpublic Map<String,Object> getAttributes()
WebSocketSessionWhen 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 WebSocketSessionpublic 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 InetSocketAddress getLocalAddress()
WebSocketSessiongetLocalAddress in interface WebSocketSessionpublic InetSocketAddress getRemoteAddress()
WebSocketSessiongetRemoteAddress in interface WebSocketSessionpublic String getAcceptedProtocol()
WebSocketSessionnull if none was specified or
negotiated successfully.getAcceptedProtocol in interface WebSocketSessionpublic List<WebSocketExtension> getExtensions()
WebSocketSessionnull if none was specified or
negotiated successfully.getExtensions 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 IOException
WebSocketSessionTextMessage or
BinaryMessage.sendMessage in interface WebSocketSessionIOExceptionpublic void close()
throws IOException
WebSocketSessionsession.close(CloseStatus.NORMAL);
close in interface WebSocketSessionIOExceptionpublic void close(CloseStatus status) throws IOException
WebSocketSessionclose in interface WebSocketSessionIOException