public abstract class AbstractClientSockJsSession extends java.lang.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) |
java.util.Map<java.lang.String,java.lang.Object> |
getAttributes()
Return the map with attributes associated with the WebSocket session.
|
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request (never
null ). |
java.lang.String |
getId()
Return a unique session identifier.
|
SockJsMessageCodec |
getMessageCodec() |
java.security.Principal |
getPrincipal()
Return a
Principal instance containing the name
of the authenticated user. |
java.net.URI |
getUri()
Return the URI used to open the WebSocket connection.
|
WebSocketHandler |
getWebSocketHandler() |
void |
handleFrame(java.lang.String payload) |
void |
handleTransportError(java.lang.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 . |
java.lang.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 java.lang.String getId()
WebSocketSession
getId
in interface WebSocketSession
public java.net.URI getUri()
WebSocketSession
getUri
in interface WebSocketSession
public HttpHeaders getHandshakeHeaders()
WebSocketSession
null
).getHandshakeHeaders
in interface WebSocketSession
public java.util.Map<java.lang.String,java.lang.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 java.security.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 java.io.IOException
WebSocketSession
TextMessage
or BinaryMessage
.sendMessage
in interface WebSocketSession
java.io.IOException
protected abstract void sendInternal(TextMessage textMessage) throws java.io.IOException
java.io.IOException
public final void close() throws java.io.IOException
WebSocketSession
session.close(CloseStatus.NORMAL);
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface WebSocketSession
java.io.IOException
public final void close(CloseStatus status)
WebSocketSession
close
in interface WebSocketSession
protected void closeInternal(CloseStatus status)
protected abstract void disconnect(CloseStatus status) throws java.io.IOException
java.io.IOException
public void handleFrame(java.lang.String payload)
public void handleTransportError(java.lang.Throwable error)
public void afterTransportClosed(@Nullable CloseStatus closeStatus)
public java.lang.String toString()
toString
in class java.lang.Object