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 (never
null ). |
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
null
).getHandshakeHeaders
in interface WebSocketSession
public Map<String,Object> getAttributes()
WebSocketSession
On the server side the map can be populated initially through a
HandshakeInterceptor
. On the client side the map can be populated via
WebSocketClient
handshake methods.
getAttributes
in interface WebSocketSession
null
)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 Closeable
close
in interface AutoCloseable
close
in interface WebSocketSession
IOException
public final void close(CloseStatus status) throws IOException
WebSocketSession
close
in interface WebSocketSession
IOException
protected void closeInternal(CloseStatus status) throws IOException
IOException
protected abstract void disconnect(CloseStatus status) throws IOException
IOException
public void handleFrame(String payload)
public void handleTransportError(Throwable error)
public void afterTransportClosed(CloseStatus closeStatus)