public abstract class AbstractWebSocketSession<T> extends Object implements NativeWebSocketSession
WebSocketSession.| Constructor and Description |
|---|
AbstractWebSocketSession(Map<String,Object> attributes)
Create a new instance and associate the given attributes with it.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkNativeSessionInitialized() |
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 abstract void |
closeInternal(CloseStatus status) |
Map<String,Object> |
getAttributes()
Return the map with attributes associated with the WebSocket session.
|
T |
getNativeSession()
Return the underlying native WebSocketSession, if available.
|
<R> R |
getNativeSession(Class<R> requiredType)
Return the underlying native WebSocketSession, if available.
|
void |
initializeNativeSession(T session) |
protected abstract void |
sendBinaryMessage(BinaryMessage message) |
void |
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message either
TextMessage or
BinaryMessage. |
protected abstract void |
sendPingMessage(PingMessage message) |
protected abstract void |
sendPongMessage(PongMessage message) |
protected abstract void |
sendTextMessage(TextMessage message) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getHandshakeHeaders, getId, getLocalAddress, getPrincipal, getRemoteAddress, getTextMessageSizeLimit, getUri, isOpen, setBinaryMessageSizeLimit, setTextMessageSizeLimitprotected final Log logger
public AbstractWebSocketSession(Map<String,Object> attributes)
attributes - attributes from the HTTP handshake to associate with the WebSocket
session; the provided attributes are copied, the original map is not used.public Map<String,Object> getAttributes()
WebSocketSessionWhen 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 WebSocketSessionpublic T getNativeSession()
NativeWebSocketSessiongetNativeSession in interface NativeWebSocketSessionnullpublic <R> R getNativeSession(Class<R> requiredType)
NativeWebSocketSessiongetNativeSession in interface NativeWebSocketSessionrequiredType - the required type of the sessionnullpublic void initializeNativeSession(T session)
protected final void checkNativeSessionInitialized()
public final void sendMessage(WebSocketMessage<?> message) throws IOException
WebSocketSessionTextMessage or
BinaryMessage.sendMessage in interface WebSocketSessionIOExceptionprotected abstract void sendTextMessage(TextMessage message) throws IOException
IOExceptionprotected abstract void sendBinaryMessage(BinaryMessage message) throws IOException
IOExceptionprotected abstract void sendPingMessage(PingMessage message) throws IOException
IOExceptionprotected abstract void sendPongMessage(PongMessage message) throws IOException
IOExceptionpublic final void close()
throws IOException
WebSocketSessionsession.close(CloseStatus.NORMAL);
close in interface WebSocketSessionIOExceptionpublic final void close(CloseStatus status) throws IOException
WebSocketSessionclose in interface WebSocketSessionIOExceptionprotected abstract void closeInternal(CloseStatus status) throws IOException
IOException