Class WebSocketOptions


  • public class WebSocketOptions
    extends java.lang.Object
    WebSockets connection options. This can be supplied to WebSocketConnection in connect(). Note that the latter copies the options provided to connect(), so any change after connect will have no effect.
    • Constructor Detail

      • WebSocketOptions

        public WebSocketOptions()
        Construct default options.
      • WebSocketOptions

        public WebSocketOptions​(WebSocketOptions other)
        Construct options as copy from other options object.
        Parameters:
        other - Options to copy.
    • Method Detail

      • setReceiveTextMessagesRaw

        public void setReceiveTextMessagesRaw​(boolean enabled)
        Receive text message as raw byte array with verified, but non-decoded UTF-8.

        DEFAULT: false

        Parameters:
        enabled - True to enable.
      • getReceiveTextMessagesRaw

        public boolean getReceiveTextMessagesRaw()
        When true, WebSockets text messages are provided as verified, but non-decoded UTF-8 in byte arrays.
        Returns:
        True, iff option is enabled.
      • setMaxFramePayloadSize

        public void setMaxFramePayloadSize​(int size)
        Set maximum frame payload size that will be accepted when receiving.

        DEFAULT: 4MB

        Parameters:
        size - Maximum size in octets for frame payload.
      • getMaxFramePayloadSize

        public int getMaxFramePayloadSize()
        Get maxium frame payload size that will be accepted when receiving.
        Returns:
        Maximum size in octets for frame payload.
      • setMaxMessagePayloadSize

        public void setMaxMessagePayloadSize​(int size)
        Set maximum message payload size (after reassembly of fragmented messages) that will be accepted when receiving.

        DEFAULT: 4MB

        Parameters:
        size - Maximum size in octets for message payload.
      • getMaxMessagePayloadSize

        public int getMaxMessagePayloadSize()
        Get maximum message payload size (after reassembly of fragmented messages) that will be accepted when receiving.
        Returns:
        Maximum size in octets for message payload.
      • setTcpNoDelay

        public void setTcpNoDelay​(boolean enabled)
        Set TCP No-Delay ("Nagle") for TCP connection.

        DEFAULT: true

        Parameters:
        enabled - True to enable TCP No-Delay.
      • getTcpNoDelay

        public boolean getTcpNoDelay()
        Get TCP No-Delay ("Nagle") for TCP connection.
        Returns:
        True, iff TCP No-Delay is enabled.
      • setSocketReceiveTimeout

        public void setSocketReceiveTimeout​(int timeoutMs)
        Set receive timeout on socket. When the TCP connection disappears, that will only be recognized by the reader after this timeout.

        DEFAULT: 200

        Parameters:
        timeoutMs - Socket receive timeout in ms.
      • getSocketReceiveTimeout

        public int getSocketReceiveTimeout()
        Get socket receive timeout.
        Returns:
        Socket receive timeout in ms.
      • setSocketConnectTimeout

        public void setSocketConnectTimeout​(int timeoutMs)
        Set connect timeout on socket. When a WebSocket connection is about to be established, the TCP socket connect will timeout after this period.

        DEFAULT: 3000

        Parameters:
        timeoutMs - Socket connect timeout in ms.
      • getSocketConnectTimeout

        public int getSocketConnectTimeout()
        Get socket connect timeout.
        Returns:
        Socket receive timeout in ms.
      • setValidateIncomingUtf8

        public void setValidateIncomingUtf8​(boolean enabled)
        Controls whether incoming text message payload is verified to be valid UTF-8.

        DEFAULT: true

        Parameters:
        enabled - True to verify incoming UTF-8.
      • getValidateIncomingUtf8

        public boolean getValidateIncomingUtf8()
        Get UTF-8 validation option.
        Returns:
        True, iff incoming UTF-8 is validated.
      • setMaskClientFrames

        public void setMaskClientFrames​(boolean enabled)
        Controls whether to mask client-to-server WebSocket frames. Beware, normally, WebSockets servers will deny non-masked c2s frames and fail the connection.

        DEFAULT: true

        Parameters:
        enabled - Set true to mask client-to-server frames.
      • getMaskClientFrames

        public boolean getMaskClientFrames()
        Get mask client frames option.
        Returns:
        True, iff client-to-server frames are masked.
      • setReconnectInterval

        public void setReconnectInterval​(int reconnectInterval)
        Set reconnect interval
        Parameters:
        reconnectInterval - Interval in ms, 0 - no reconnection
      • getReconnectInterval

        public int getReconnectInterval()
      • getTLSEnabledProtocols

        public java.lang.String[] getTLSEnabledProtocols()
        Get TLS enabled protocols.
        Returns:
      • setTLSEnabledProtocols

        public void setTLSEnabledProtocols​(java.lang.String[] protocols)
        Set TLS enabled protocols. Eg. protocols = new String[]{"TLSv1.1", "TLSv1.2"}
        Parameters:
        protocols -
      • setAutoPingInterval

        public void setAutoPingInterval​(int seconds)
      • getAutoPingInterval

        public int getAutoPingInterval()
      • setAutoPingTimeout

        public void setAutoPingTimeout​(int seconds)
      • getAutoPingTimeout

        public int getAutoPingTimeout()