io.vertx.ext.web.handler.sockjs

## Class SockJSHandlerOptions

- java.lang.Object
- - io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions

-     public class SockJSHandlerOptions
      extends Object

  Options for configuring a SockJS handler
  Author:
    Tim Fox, Paulo Lopes

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static long` | `DEFAULT_HEARTBEAT_INTERVAL` The default interval between heartbeat packets.
    `static boolean` | `DEFAULT_INSERT_JSESSIONID` Whether a `JSESSIONID` cookie should be inserted by default = true.
    `static String` | `DEFAULT_LIBRARY_URL` The default SockJS library URL to load in iframe when a transport does not support cross-domain communication natively.
    `static boolean` | `DEFAULT_LOCAL_WRITE_HANDLER` Whether the `writeHandler` should be registered as local by default = true.
    `static int` | `DEFAULT_MAX_BYTES_STREAMING` The default maximum number of bytes an HTTP streaming request can send.
    `static boolean` | `DEFAULT_REGISTER_WRITE_HANDLER` Whether a `writeHandler` should be registered by default = false.
    `static long` | `DEFAULT_SESSION_TIMEOUT` The default delay before sending a `close` event to a silent client.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SockJSHandlerOptions()` Default constructor.
    `SockJSHandlerOptions(JsonObject json)` Constructor to create options from JSON.
    `SockJSHandlerOptions(SockJSHandlerOptions other)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SockJSHandlerOptions` | `addDisabledTransport(String subProtocol)` Add a transport (by name) to the set of disabled transports.
    `Set<String>` | `getDisabledTransports()`
    `long` | `getHeartbeatInterval()`
    `String` | `getLibraryURL()`
    `int` | `getMaxBytesStreaming()`
    `String` | `getOrigin()`
    `long` | `getSessionTimeout()`
    `boolean` | `isInsertJSESSIONID()`
    `boolean` | `isLocalWriteHandler()`
    `boolean` | `isRegisterWriteHandler()`
    `SockJSHandlerOptions` | `setHeartbeatInterval(long heartbeatInterval)` In order to keep proxies and load balancers from closing long running HTTP requests we need to pretend that the connection is active and send a heartbeat packet once in a while.
    `SockJSHandlerOptions` | `setInsertJSESSIONID(boolean insertJSESSIONID)` Whether to insert a `JSESSIONID` cookie so load-balancers ensure requests for a specific SockJS session are always routed to the correct server.
    `SockJSHandlerOptions` | `setLibraryURL(String libraryURL)` Transports which don't support cross-domain communication natively use an iframe trick.
    `SockJSHandlerOptions` | `setLocalWriteHandler(boolean localWriteHandler)` Whether the `writeHandler` should be local only or cluster-wide.
    `SockJSHandlerOptions` | `setMaxBytesStreaming(int maxBytesStreaming)` Most streaming transports save responses on the client side and don't free memory used by delivered messages.
    `SockJSHandlerOptions` | `setOrigin(String origin)` Set the origin to be verified before a websocket upgrade happens.
    `SockJSHandlerOptions` | `setRegisterWriteHandler(boolean registerWriteHandler)` Whether a `writeHandler` should be registered on the `EventBus`.
    `SockJSHandlerOptions` | `setSessionTimeout(long sessionTimeout)` Set the delay before the server sends a `close` event when a client receiving connection has not been seen for a while.

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

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

- - ### Field Detail

    - #### DEFAULT_SESSION_TIMEOUT

          public static final long DEFAULT_SESSION_TIMEOUT

      The default delay before sending a `close` event to a silent client.
      See Also:
        Constant Field Values

    - #### DEFAULT_INSERT_JSESSIONID

          public static final boolean DEFAULT_INSERT_JSESSIONID

      Whether a `JSESSIONID` cookie should be inserted by default = true.
      See Also:
        Constant Field Values

    - #### DEFAULT_HEARTBEAT_INTERVAL

          public static final long DEFAULT_HEARTBEAT_INTERVAL

      The default interval between heartbeat packets.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_BYTES_STREAMING

          public static final int DEFAULT_MAX_BYTES_STREAMING

      The default maximum number of bytes an HTTP streaming request can send.
      See Also:
        Constant Field Values

    - #### DEFAULT_LIBRARY_URL

          public static final String DEFAULT_LIBRARY_URL

      The default SockJS library URL to load in iframe when a transport does not support cross-domain communication natively.
      See Also:
        Constant Field Values

    - #### DEFAULT_REGISTER_WRITE_HANDLER

          public static final boolean DEFAULT_REGISTER_WRITE_HANDLER

      Whether a `writeHandler` should be registered by default = false.
      See Also:
        Constant Field Values

    - #### DEFAULT_LOCAL_WRITE_HANDLER

          public static final boolean DEFAULT_LOCAL_WRITE_HANDLER

      Whether the `writeHandler` should be registered as local by default = true.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SockJSHandlerOptions

          public SockJSHandlerOptions(SockJSHandlerOptions other)

      Copy constructor.
      Parameters:
        `other` - the options to copy

    - #### SockJSHandlerOptions

          public SockJSHandlerOptions()

      Default constructor.

    - #### SockJSHandlerOptions

          public SockJSHandlerOptions(JsonObject json)

      Constructor to create options from JSON.
      Parameters:
        `json` - the JSON

  - ### Method Detail

    - #### getSessionTimeout

          public long getSessionTimeout()

      Returns:
        the session timeout in milliseconds

    - #### setSessionTimeout

          public SockJSHandlerOptions setSessionTimeout(long sessionTimeout)

      Set the delay before the server sends a `close` event when a client receiving connection has not been seen for a while.

      Defaults to 5 seconds.

      Parameters:
        `sessionTimeout` - timeout in milliseconds
      Returns:
        a reference to this, so the API can be used fluently

    - #### isInsertJSESSIONID

          public boolean isInsertJSESSIONID()

      Returns:
        true if a `JSESSIONID` cookie should be inserted, false otherwise

    - #### setInsertJSESSIONID

          public SockJSHandlerOptions setInsertJSESSIONID(boolean insertJSESSIONID)

      Whether to insert a `JSESSIONID` cookie so load-balancers ensure requests for a specific SockJS session are always routed to the correct server.

      Defaults to `true`.

      Parameters:
        `insertJSESSIONID` - true if a `JSESSIONID` cookie should be inserted, false otherwise
      Returns:
        a reference to this, so the API can be used fluently

    - #### getHeartbeatInterval

          public long getHeartbeatInterval()

      Returns:
        the hearbeat packet interval in milliseconds

    - #### setHeartbeatInterval

          public SockJSHandlerOptions setHeartbeatInterval(long heartbeatInterval)

      In order to keep proxies and load balancers from closing long running HTTP requests we need to pretend that the connection is active and send a heartbeat packet once in a while. This setting controls how often this is done.

      Defaults to 25 seconds.

      Parameters:
        `heartbeatInterval` - interval in milliseconds
      Returns:
        a reference to this, so the API can be used fluently

    - #### getMaxBytesStreaming

          public int getMaxBytesStreaming()

      Returns:
        maximum number of bytes an HTTP streaming request can send

    - #### setMaxBytesStreaming

          public SockJSHandlerOptions setMaxBytesStreaming(int maxBytesStreaming)

      Most streaming transports save responses on the client side and don't free memory used by delivered messages. Such transports need to be garbage-collected once in a while.

      This setting controls the maximum number of bytes that can be sent over a single HTTP streaming request before it will be closed. After that the client needs to open new request. Setting this value to one effectively disables streaming and will make streaming transports to behave like polling transports.

      Defaults to 128K.

      Parameters:
        `maxBytesStreaming` - maximum number of bytes an HTTP streaming request can send
      Returns:
        a reference to this, so the API can be used fluently

    - #### getLibraryURL

          public String getLibraryURL()

      Returns:
        the SockJS library URL to load in iframe when a transport does not support cross-domain communication natively

    - #### setLibraryURL

          public SockJSHandlerOptions setLibraryURL(String libraryURL)

      Transports which don't support cross-domain communication natively use an iframe trick. A simple page is served from the SockJS server (using its foreign domain) and is placed in an invisible iframe.

      Code run from this iframe doesn't need to worry about cross-domain issues, as it's being run from domain local to the SockJS server. This iframe also does need to load SockJS javascript client library, and this option lets you specify its URL.

      Parameters:
        `libraryURL` - the SockJS library URL
      Returns:
        a reference to this, so the API can be used fluently

    - #### addDisabledTransport

          public SockJSHandlerOptions addDisabledTransport(String subProtocol)

      Add a transport (by name) to the set of disabled transports.
      Parameters:
        `subProtocol` - the transport to disable
      Returns:
        a reference to this, so the API can be used fluently
      See Also:
        `Transport`

    - #### getDisabledTransports

          public Set<String> getDisabledTransports()

      Returns:
        the set of transports to disable

    - #### isRegisterWriteHandler

          public boolean isRegisterWriteHandler()

      Returns:
        true if a `writeHandler` should be registered on the `EventBus`, false otherwise
      See Also:
        `SockJSSocket.writeHandlerID()`

    - #### setRegisterWriteHandler

          public SockJSHandlerOptions setRegisterWriteHandler(boolean registerWriteHandler)

      Whether a `writeHandler` should be registered on the `EventBus`.

      Defaults to `false`.

      Parameters:
        `registerWriteHandler` - true to register a `writeHandler`
      Returns:
        a reference to this, so the API can be used fluently
      See Also:
        `SockJSSocket.writeHandlerID()`

    - #### isLocalWriteHandler

          public boolean isLocalWriteHandler()

      Returns:
        true if the `writeHandler` is local only, false otherwise
      See Also:
        `SockJSSocket.writeHandlerID()`

    - #### setLocalWriteHandler

          public SockJSHandlerOptions setLocalWriteHandler(boolean localWriteHandler)

      Whether the `writeHandler` should be local only or cluster-wide.

      Defaults to `true`.

      Parameters:
        `localWriteHandler` - true to register locally, false otherwise
      Returns:
        a reference to this, so the API can be used fluently
      See Also:
        `SockJSSocket.writeHandlerID()`

    - #### getOrigin

          public String getOrigin()

      Returns:
        the origin associated with this bridge

    - #### setOrigin

          public SockJSHandlerOptions setOrigin(String origin)

      Set the origin to be verified before a websocket upgrade happens.

      Defaults to `null`.

      Parameters:
        `origin` - web origin
      Returns:
        a reference to this, so the API can be used fluently

Copyright © 2023 Eclipse. All rights reserved.