org.springframework.web.socket.sockjs.transport.session

## Class StreamingSockJsSession

- java.lang.Object
- - org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession
  - - org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession
    - - org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession

- All Implemented Interfaces:
    SockJsSession, WebSocketSession

      public class StreamingSockJsSession
      extends AbstractHttpSockJsSession

  A SockJS session for use with streaming HTTP transports.
  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Field Summary

    - ### Fields inherited from class org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession

      `DISCONNECTED_CLIENT_LOG_CATEGORY, disconnectedClientLogger, logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StreamingSockJsSession(String sessionId, SockJsServiceConfig config, WebSocketHandler wsHandler, Map<String,Object> attributes)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `flushCache()` Only called if the connection is currently active
    `void` | `handleInitialRequest(ServerHttpRequest request, ServerHttpResponse response, SockJsFrameFormat frameFormat)` Handle the first HTTP request, i.e.
    `protected void` | `resetRequest()`
    `protected void` | `writeFrameInternal(SockJsFrame frame)`

    - ### Methods inherited from class org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession

      `disconnect, getAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getHandshakeHeaders, getLocalAddress, getMessageCache, getPrincipal, getRemoteAddress, getResponse, getTextMessageSizeLimit, getUri, handleSuccessiveRequest, isActive, sendMessageInternal, setAcceptedProtocol, setBinaryMessageSizeLimit, setTextMessageSizeLimit, startAsyncRequest, writePrelude`

    - ### Methods inherited from class org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession

      `cancelHeartbeat, close, close, delegateConnectionClosed, delegateConnectionEstablished, delegateError, delegateMessages, disableHeartbeat, getAttributes, getId, getSockJsServiceConfig, getTimeSinceLastActive, isClosed, isNew, isOpen, scheduleHeartbeat, sendHeartbeat, sendMessage, toString, tryCloseWithSockJsTransportError, updateLastActiveTime, writeFrame`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### StreamingSockJsSession

          public StreamingSockJsSession(String sessionId,
                                        SockJsServiceConfig config,
                                        WebSocketHandler wsHandler,
                                        Map<String,Object> attributes)

  - ### Method Detail

    - #### handleInitialRequest

          public void handleInitialRequest(ServerHttpRequest request,
                                           ServerHttpResponse response,
                                           SockJsFrameFormat frameFormat)
                                    throws SockJsException

      Description copied from class: `AbstractHttpSockJsSession`
      Handle the first HTTP request, i.e. the one that starts a SockJS session. Write a prelude to the response (if needed), send the SockJS "open" frame to indicate to the client the session is opened, and invoke the delegate WebSocketHandler to provide it with the newly opened session.

      The "xhr" and "jsonp" (polling-based) transports completes the initial request as soon as the open frame is sent. Following that the client should start a successive polling request within the same SockJS session.

      The "xhr_streaming", "eventsource", and "htmlfile" transports are streaming based and will leave the initial request open in order to stream one or more messages. However, even streaming based transports eventually recycle the long running request, after a certain number of bytes have been streamed (128K by default), and allow the client to start a successive request within the same SockJS session.

      Overrides:
        `handleInitialRequest` in class `AbstractHttpSockJsSession`
      Parameters:
        `request` - the current request
        `response` - the current response
        `frameFormat` - the transport-specific SocksJS frame format to use
      Throws:
        `SockJsException`
      See Also:
        `AbstractHttpSockJsSession.handleSuccessiveRequest(org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse, org.springframework.web.socket.sockjs.frame.SockJsFrameFormat)`

    - #### flushCache

          protected void flushCache()
                             throws SockJsTransportFailureException

      Description copied from class: `AbstractHttpSockJsSession`
      Only called if the connection is currently active
      Specified by:
        `flushCache` in class `AbstractHttpSockJsSession`
      Throws:
        `SockJsTransportFailureException`

    - #### resetRequest

          protected void resetRequest()

      Overrides:
        `resetRequest` in class `AbstractHttpSockJsSession`

    - #### writeFrameInternal

          protected void writeFrameInternal(SockJsFrame frame)
                                     throws IOException

      Overrides:
        `writeFrameInternal` in class `AbstractHttpSockJsSession`
      Throws:
        `IOException`