public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession
DISCONNECTED_CLIENT_LOG_CATEGORY, disconnectedClientLogger, logger, responseLock| Constructor and Description |
|---|
AbstractHttpSockJsSession(java.lang.String id,
SockJsServiceConfig config,
WebSocketHandler wsHandler,
java.util.Map<java.lang.String,java.lang.Object> attributes) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
disconnect(CloseStatus status)
Actually close the underlying WebSocket session or in the case of HTTP
transports complete the underlying request.
|
protected abstract void |
flushCache()
Called when the connection is active and ready to write to the response.
|
java.lang.String |
getAcceptedProtocol()
Return the selected sub-protocol to use.
|
int |
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.
|
java.util.List<WebSocketExtension> |
getExtensions()
Determine the negotiated extensions.
|
HttpHeaders |
getHandshakeHeaders()
Return the headers used in the handshake request (never
null). |
java.net.InetSocketAddress |
getLocalAddress()
Return the address on which the request was received.
|
protected java.util.Queue<java.lang.String> |
getMessageCache()
Return the SockJS buffer for messages stored transparently between polling
requests.
|
java.security.Principal |
getPrincipal()
Return a
Principal instance containing the name
of the authenticated user. |
java.net.InetSocketAddress |
getRemoteAddress()
Return the address of the remote client.
|
int |
getTextMessageSizeLimit()
Get the configured maximum size for an incoming text message.
|
java.net.URI |
getUri()
Return the URI used to open the WebSocket connection.
|
void |
handleInitialRequest(ServerHttpRequest request,
ServerHttpResponse response,
SockJsFrameFormat frameFormat)
Handle the first request for receiving messages on a SockJS HTTP transport
based session.
|
protected abstract void |
handleRequestInternal(ServerHttpRequest request,
ServerHttpResponse response,
boolean initialRequest)
Invoked when a SockJS transport request is received.
|
void |
handleSuccessiveRequest(ServerHttpRequest request,
ServerHttpResponse response,
SockJsFrameFormat frameFormat)
Handle all requests, except the first one, to receive messages on a SockJS
HTTP transport based session.
|
boolean |
isActive()
Polling and Streaming sessions periodically close the current HTTP request and
wait for the next request to come through.
|
protected abstract boolean |
isStreaming()
Deprecated.
as of 4.2, since this method is no longer used.
|
protected void |
resetRequest() |
protected void |
sendMessageInternal(java.lang.String message) |
void |
setAcceptedProtocol(java.lang.String protocol)
Unlike WebSocket where sub-protocol negotiation is part of the initial
handshake, in HTTP transports the same negotiation must be emulated and
the selected protocol set through this setter.
|
void |
setBinaryMessageSizeLimit(int messageSizeLimit)
Configure the maximum size for an incoming binary message.
|
void |
setTextMessageSizeLimit(int messageSizeLimit)
Configure the maximum size for an incoming text message.
|
protected void |
writeFrameInternal(SockJsFrame frame) |
protected void |
writePrelude(ServerHttpRequest request,
ServerHttpResponse response)
Deprecated.
as of 4.2 this method is deprecated since the prelude is written
in
handleRequestInternal(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, boolean) of the StreamingSockJsSession subclass. |
cancelHeartbeat, close, close, delegateConnectionClosed, delegateConnectionEstablished, delegateError, delegateMessages, disableHeartbeat, getAttributes, getId, getMessageCodec, getSockJsServiceConfig, getTimeSinceLastActive, isClosed, isNew, isOpen, scheduleHeartbeat, sendHeartbeat, sendMessage, toString, tryCloseWithSockJsTransportError, updateLastActiveTime, writeFramepublic AbstractHttpSockJsSession(java.lang.String id,
SockJsServiceConfig config,
WebSocketHandler wsHandler,
java.util.Map<java.lang.String,java.lang.Object> attributes)
public java.net.URI getUri()
WebSocketSessionpublic HttpHeaders getHandshakeHeaders()
WebSocketSessionnull).public java.security.Principal getPrincipal()
WebSocketSessionPrincipal instance containing the name
of the authenticated user.
If the user has not been authenticated, the method returns null.
public java.net.InetSocketAddress getLocalAddress()
WebSocketSessionpublic java.net.InetSocketAddress getRemoteAddress()
WebSocketSessionpublic void setAcceptedProtocol(java.lang.String protocol)
protocol - the sub-protocol to setpublic java.lang.String getAcceptedProtocol()
null if no protocol
was specified or negotiated successfullyprotected java.util.Queue<java.lang.String> getMessageCache()
TransportHandlingSockJsServicepublic boolean isActive()
AbstractSockJsSessionisActive in class AbstractSockJsSessionpublic void setTextMessageSizeLimit(int messageSizeLimit)
WebSocketSessionpublic int getTextMessageSizeLimit()
WebSocketSessionpublic void setBinaryMessageSizeLimit(int messageSizeLimit)
WebSocketSessionpublic int getBinaryMessageSizeLimit()
WebSocketSessionpublic java.util.List<WebSocketExtension> getExtensions()
WebSocketSession@Deprecated protected abstract boolean isStreaming()
public void handleInitialRequest(ServerHttpRequest request, ServerHttpResponse response, SockJsFrameFormat frameFormat) throws SockJsException
Long polling-based transports (e.g. "xhr", "jsonp") complete the request after writing the open frame. Streaming-based transports ("xhr_streaming", "eventsource", and "htmlfile") leave the response open longer for further streaming of message frames but will also close it eventually after some amount of data has been sent.
request - the current requestresponse - the current responseframeFormat - the transport-specific SocksJS frame format to useSockJsExceptionpublic void handleSuccessiveRequest(ServerHttpRequest request, ServerHttpResponse response, SockJsFrameFormat frameFormat) throws SockJsException
Long polling-based transports (e.g. "xhr", "jsonp") complete the request after writing any buffered message frames (or the next one). Streaming-based transports ("xhr_streaming", "eventsource", and "htmlfile") leave the response open longer for further streaming of message frames but will also close it eventually after some amount of data has been sent.
request - the current requestresponse - the current responseframeFormat - the transport-specific SocksJS frame format to useSockJsExceptionprotected abstract void handleRequestInternal(ServerHttpRequest request, ServerHttpResponse response, boolean initialRequest) throws java.io.IOException
request - the current requestresponse - the current responseinitialRequest - whether it is the first request for the sessionjava.io.IOExceptionprotected final void sendMessageInternal(java.lang.String message)
throws SockJsTransportFailureException
sendMessageInternal in class AbstractSockJsSessionSockJsTransportFailureExceptionprotected abstract void flushCache()
throws SockJsTransportFailureException
SockJsTransportFailureException@Deprecated protected void writePrelude(ServerHttpRequest request, ServerHttpResponse response) throws java.io.IOException
handleRequestInternal(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, boolean) of the StreamingSockJsSession subclass.java.io.IOExceptionprotected void disconnect(CloseStatus status)
AbstractSockJsSessiondisconnect in class AbstractSockJsSessionprotected void resetRequest()
protected void writeFrameInternal(SockJsFrame frame) throws java.io.IOException
writeFrameInternal in class AbstractSockJsSessionjava.io.IOException