public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
WebSocketSession
for use with the standard WebSocket for Java API.logger
Constructor and Description |
---|
StandardWebSocketSession(HttpHeaders headers,
Map<String,Object> attributes,
InetSocketAddress localAddress,
InetSocketAddress remoteAddress)
Constructor for a standard WebSocket session.
|
StandardWebSocketSession(HttpHeaders headers,
Map<String,Object> attributes,
InetSocketAddress localAddress,
InetSocketAddress remoteAddress,
Principal user)
Constructor that associates a user with the WebSocket session.
|
Modifier and Type | Method and Description |
---|---|
protected void |
closeInternal(CloseStatus status) |
String |
getAcceptedProtocol()
Return the negotiated sub-protocol.
|
int |
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.
|
List<WebSocketExtension> |
getExtensions()
Determine the negotiated extensions.
|
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request (never
null ). |
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.
|
void |
initializeNativeSession(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, toString
public StandardWebSocketSession(@Nullable HttpHeaders headers, @Nullable Map<String,Object> attributes, @Nullable InetSocketAddress localAddress, @Nullable 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 Map<String,Object> attributes, @Nullable InetSocketAddress localAddress, @Nullable InetSocketAddress remoteAddress, @Nullable 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 String getId()
WebSocketSession
@Nullable public URI getUri()
WebSocketSession
public HttpHeaders getHandshakeHeaders()
WebSocketSession
null
).public String getAcceptedProtocol()
WebSocketSession
null
if no protocol
was specified or negotiated successfullypublic List<WebSocketExtension> getExtensions()
WebSocketSession
public Principal getPrincipal()
WebSocketSession
Principal
instance containing the name
of the authenticated user.
If the user has not been authenticated, the method returns null
.
@Nullable public InetSocketAddress getLocalAddress()
WebSocketSession
@Nullable public InetSocketAddress getRemoteAddress()
WebSocketSession
public void setTextMessageSizeLimit(int messageSizeLimit)
WebSocketSession
public int getTextMessageSizeLimit()
WebSocketSession
public void setBinaryMessageSizeLimit(int messageSizeLimit)
WebSocketSession
public int getBinaryMessageSizeLimit()
WebSocketSession
public boolean isOpen()
WebSocketSession
public void initializeNativeSession(Session session)
initializeNativeSession
in class AbstractWebSocketSession<Session>
protected void sendTextMessage(TextMessage message) throws IOException
sendTextMessage
in class AbstractWebSocketSession<Session>
IOException
protected void sendBinaryMessage(BinaryMessage message) throws IOException
sendBinaryMessage
in class AbstractWebSocketSession<Session>
IOException
protected void sendPingMessage(PingMessage message) throws IOException
sendPingMessage
in class AbstractWebSocketSession<Session>
IOException
protected void sendPongMessage(PongMessage message) throws IOException
sendPongMessage
in class AbstractWebSocketSession<Session>
IOException
protected void closeInternal(CloseStatus status) throws IOException
closeInternal
in class AbstractWebSocketSession<Session>
IOException