public class StandardWebSocketSession extends AbstractWebSocketSession<javax.websocket.Session>
WebSocketSession for use with the standard WebSocket for Java API.idGenerator, logger| Constructor and Description |
|---|
StandardWebSocketSession(HttpHeaders headers,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.net.InetSocketAddress localAddress,
java.net.InetSocketAddress remoteAddress)
Constructor for a standard WebSocket session.
|
StandardWebSocketSession(HttpHeaders headers,
java.util.Map<java.lang.String,java.lang.Object> attributes,
java.net.InetSocketAddress localAddress,
java.net.InetSocketAddress remoteAddress,
java.security.Principal user)
Constructor that associates a user with the WebSocket session.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeInternal(CloseStatus status) |
java.lang.String |
getAcceptedProtocol()
Return the negotiated sub-protocol.
|
int |
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.
|
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.
|
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.
|
void |
initializeNativeSession(javax.websocket.Session session) |
boolean |
isOpen()
Return whether the connection is still open.
|
protected void |
sendBinaryMessage(BinaryMessage message) |
protected void |
sendPingMessage(PingMessage message) |
protected void |
sendPongMessage(PongMessage message) |
protected void |
sendTextMessage(TextMessage message) |
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.
|
checkNativeSessionInitialized, close, close, getAttributes, getNativeSession, getNativeSession, sendMessage, toStringpublic StandardWebSocketSession(@Nullable HttpHeaders headers, @Nullable java.util.Map<java.lang.String,java.lang.Object> attributes, @Nullable java.net.InetSocketAddress localAddress, @Nullable java.net.InetSocketAddress remoteAddress)
headers - the headers of the handshake requestattributes - attributes from the HTTP handshake to associate with the WebSocket
session; the provided attributes are copied, the original map is not used.localAddress - the address on which the request was receivedremoteAddress - the address of the remote clientpublic StandardWebSocketSession(@Nullable HttpHeaders headers, @Nullable java.util.Map<java.lang.String,java.lang.Object> attributes, @Nullable java.net.InetSocketAddress localAddress, @Nullable java.net.InetSocketAddress remoteAddress, @Nullable java.security.Principal user)
headers - the headers of the handshake requestattributes - attributes from the HTTP handshake to associate with the WebSocket sessionlocalAddress - the address on which the request was receivedremoteAddress - the address of the remote clientuser - the user associated with the session; if null we'll
fallback on the user available in the underlying WebSocket sessionpublic java.lang.String getId()
WebSocketSession@Nullable public java.net.URI getUri()
WebSocketSessionpublic HttpHeaders getHandshakeHeaders()
WebSocketSessionnull).public java.lang.String getAcceptedProtocol()
WebSocketSessionnull if no protocol
was specified or negotiated successfullypublic java.util.List<WebSocketExtension> getExtensions()
WebSocketSessionpublic java.security.Principal getPrincipal()
WebSocketSessionPrincipal instance containing the name
of the authenticated user.
If the user has not been authenticated, the method returns null.
@Nullable public java.net.InetSocketAddress getLocalAddress()
WebSocketSession@Nullable public java.net.InetSocketAddress getRemoteAddress()
WebSocketSessionpublic void setTextMessageSizeLimit(int messageSizeLimit)
WebSocketSessionpublic int getTextMessageSizeLimit()
WebSocketSessionpublic void setBinaryMessageSizeLimit(int messageSizeLimit)
WebSocketSessionpublic int getBinaryMessageSizeLimit()
WebSocketSessionpublic boolean isOpen()
WebSocketSessionpublic void initializeNativeSession(javax.websocket.Session session)
initializeNativeSession in class AbstractWebSocketSession<javax.websocket.Session>protected void sendTextMessage(TextMessage message) throws java.io.IOException
sendTextMessage in class AbstractWebSocketSession<javax.websocket.Session>java.io.IOExceptionprotected void sendBinaryMessage(BinaryMessage message) throws java.io.IOException
sendBinaryMessage in class AbstractWebSocketSession<javax.websocket.Session>java.io.IOExceptionprotected void sendPingMessage(PingMessage message) throws java.io.IOException
sendPingMessage in class AbstractWebSocketSession<javax.websocket.Session>java.io.IOExceptionprotected void sendPongMessage(PongMessage message) throws java.io.IOException
sendPongMessage in class AbstractWebSocketSession<javax.websocket.Session>java.io.IOExceptionprotected void closeInternal(CloseStatus status) throws java.io.IOException
closeInternal in class AbstractWebSocketSession<javax.websocket.Session>java.io.IOException