public abstract class AbstractClientSockJsSession extends Object implements WebSocketSession
WebSocketSession
.
Provides processing of incoming SockJS message frames and delegates lifecycle
events and messages to the (application) WebSocketHandler
.
Sub-classes implement actual send as well as disconnect logic.Modifier | Constructor and Description |
---|---|
protected |
AbstractClientSockJsSession(TransportRequest request,
WebSocketHandler handler,
SettableListenableFuture<WebSocketSession> connectFuture) |
Modifier and Type | Method and Description |
---|---|
void |
afterTransportClosed(CloseStatus closeStatus) |
void |
close()
Close the WebSocket connection with status 1000, i.e.
|
void |
close(CloseStatus status)
Close the WebSocket connection with the given close status.
|
protected void |
closeInternal(CloseStatus status) |
protected abstract void |
disconnect(CloseStatus status) |
Map<String,Object> |
getAttributes()
Return the map with attributes associated with the WebSocket session.
|
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request.
|
String |
getId()
Return a unique session identifier.
|
SockJsMessageCodec |
getMessageCodec() |
Principal |
getPrincipal()
Return a
Principal instance containing the name of the
authenticated user. |
URI |
getUri()
Return the URI used to open the WebSocket connection.
|
WebSocketHandler |
getWebSocketHandler() |
void |
handleFrame(String payload) |
void |
handleTransportError(Throwable error) |
boolean |
isDisconnected() |
boolean |
isOpen()
Return whether the connection is still open.
|
protected abstract void |
sendInternal(TextMessage textMessage) |
void |
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message either
TextMessage or
BinaryMessage . |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getLocalAddress, getRemoteAddress, getTextMessageSizeLimit, setBinaryMessageSizeLimit, setTextMessageSizeLimit
protected final Log logger
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler, SettableListenableFuture<WebSocketSession> connectFuture)
public String getId()
WebSocketSession
getId
in interface WebSocketSession
public URI getUri()
WebSocketSession
getUri
in interface WebSocketSession
public HttpHeaders getHandshakeHeaders()
WebSocketSession
getHandshakeHeaders
in interface WebSocketSession
public Map<String,Object> getAttributes()
WebSocketSession
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.
getAttributes
in interface 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
.getPrincipal
in interface WebSocketSession
public SockJsMessageCodec getMessageCodec()
public WebSocketHandler getWebSocketHandler()
public boolean isOpen()
WebSocketSession
isOpen
in interface WebSocketSession
public boolean isDisconnected()
public final void sendMessage(WebSocketMessage<?> message) throws IOException
WebSocketSession
TextMessage
or
BinaryMessage
.sendMessage
in interface WebSocketSession
IOException
protected abstract void sendInternal(TextMessage textMessage) throws IOException
IOException
public final void close() throws IOException
WebSocketSession
session.close(CloseStatus.NORMAL);
close
in interface WebSocketSession
IOException
public final void close(CloseStatus status)
WebSocketSession
close
in interface WebSocketSession
protected void closeInternal(CloseStatus status)
protected abstract void disconnect(CloseStatus status) throws IOException
IOException
public void handleFrame(String payload)
public void handleTransportError(Throwable error)
public void afterTransportClosed(CloseStatus closeStatus)