public class StandardWebSocketSession extends AbstractWebSocketSession<javax.websocket.Session>
WebSocketSession
for use with the standard WebSocket for Java API.logger
Constructor and Description |
---|
StandardWebSocketSession(HttpHeaders headers,
Map<String,Object> handshakeAttributes,
InetSocketAddress localAddress,
InetSocketAddress remoteAddress)
Class constructor.
|
StandardWebSocketSession(HttpHeaders headers,
Map<String,Object> handshakeAttributes,
InetSocketAddress localAddress,
InetSocketAddress remoteAddress,
Principal user)
Class 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 or
null if none was specified or
negotiated successfully. |
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.
|
URI |
getUri()
Return the URI used to open the WebSocket connection.
|
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) |
checkNativeSessionInitialized, close, close, getHandshakeAttributes, getNativeSession, getNativeSession, initializeNativeSession, sendMessage, toString
public StandardWebSocketSession(HttpHeaders headers, Map<String,Object> handshakeAttributes, InetSocketAddress localAddress, InetSocketAddress remoteAddress)
headers
- the headers of the handshake requesthandshakeAttributes
- attributes from the HTTP handshake to make available
through the WebSocket sessionlocalAddress
- the address on which the request was receivedremoteAddress
- the address of the remote clientpublic StandardWebSocketSession(HttpHeaders headers, Map<String,Object> handshakeAttributes, InetSocketAddress localAddress, InetSocketAddress remoteAddress, Principal user)
headers
- the headers of the handshake requesthandshakeAttributes
- attributes from the HTTP handshake to make available
through the WebSocket sessionlocalAddress
- the address on which the request was receivedremoteAddress
- the address of the remote clientuser
- the user associated with the session; can be left
null
in which case, we'll fallback on the user available viapublic String getId()
WebSocketSession
public URI getUri()
WebSocketSession
public HttpHeaders getHandshakeHeaders()
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
.public InetSocketAddress getLocalAddress()
WebSocketSession
public InetSocketAddress getRemoteAddress()
WebSocketSession
public String getAcceptedProtocol()
WebSocketSession
null
if none was specified or
negotiated successfully.public List<WebSocketExtension> getExtensions()
WebSocketSession
null
if none was specified or
negotiated successfully.public boolean isOpen()
WebSocketSession
protected void sendTextMessage(TextMessage message) throws IOException
sendTextMessage
in class AbstractWebSocketSession<javax.websocket.Session>
IOException
protected void sendBinaryMessage(BinaryMessage message) throws IOException
sendBinaryMessage
in class AbstractWebSocketSession<javax.websocket.Session>
IOException
protected void sendPingMessage(PingMessage message) throws IOException
sendPingMessage
in class AbstractWebSocketSession<javax.websocket.Session>
IOException
protected void sendPongMessage(PongMessage message) throws IOException
sendPongMessage
in class AbstractWebSocketSession<javax.websocket.Session>
IOException
protected void closeInternal(CloseStatus status) throws IOException
closeInternal
in class AbstractWebSocketSession<javax.websocket.Session>
IOException