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