public interface WebSocketSession
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.
|
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.
|
String |
getId()
Return a unique session identifier.
|
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 getId()
URI getUri()
HttpHeaders getHandshakeHeaders()
Map<String,Object> getAttributes()
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.
Principal getPrincipal()
Principal
instance containing the name of the
authenticated user. If the user has not been authenticated, the method returns
null
.InetSocketAddress getLocalAddress()
InetSocketAddress getRemoteAddress()
String getAcceptedProtocol()
null
if none was specified or
negotiated successfully.void setTextMessageSizeLimit(int messageSizeLimit)
int getTextMessageSizeLimit()
void setBinaryMessageSizeLimit(int messageSizeLimit)
int getBinaryMessageSizeLimit()
List<WebSocketExtension> getExtensions()
null
if none was specified or
negotiated successfully.void sendMessage(WebSocketMessage<?> message) throws IOException
TextMessage
or BinaryMessage
.IOException
boolean isOpen()
void close() throws IOException
session.close(CloseStatus.NORMAL);
IOException
void close(CloseStatus status) throws IOException
IOException