Class WebSocketOptions
- java.lang.Object
-
- io.crossbar.autobahn.websocket.types.WebSocketOptions
-
public class WebSocketOptions extends java.lang.ObjectWebSockets 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 Summary
Constructors Constructor Description WebSocketOptions()Construct default options.WebSocketOptions(WebSocketOptions other)Construct options as copy from other options object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAutoPingInterval()intgetAutoPingTimeout()booleangetMaskClientFrames()Get mask client frames option.intgetMaxFramePayloadSize()Get maxium frame payload size that will be accepted when receiving.intgetMaxMessagePayloadSize()Get maximum message payload size (after reassembly of fragmented messages) that will be accepted when receiving.booleangetReceiveTextMessagesRaw()When true, WebSockets text messages are provided as verified, but non-decoded UTF-8 in byte arrays.intgetReconnectInterval()intgetSocketConnectTimeout()Get socket connect timeout.intgetSocketReceiveTimeout()Get socket receive timeout.booleangetTcpNoDelay()Get TCP No-Delay ("Nagle") for TCP connection.java.lang.String[]getTLSEnabledProtocols()Get TLS enabled protocols.booleangetValidateIncomingUtf8()Get UTF-8 validation option.voidsetAutoPingInterval(int seconds)voidsetAutoPingTimeout(int seconds)voidsetMaskClientFrames(boolean enabled)Controls whether to mask client-to-server WebSocket frames.voidsetMaxFramePayloadSize(int size)Set maximum frame payload size that will be accepted when receiving.voidsetMaxMessagePayloadSize(int size)Set maximum message payload size (after reassembly of fragmented messages) that will be accepted when receiving.voidsetReceiveTextMessagesRaw(boolean enabled)Receive text message as raw byte array with verified, but non-decoded UTF-8.voidsetReconnectInterval(int reconnectInterval)Set reconnect intervalvoidsetSocketConnectTimeout(int timeoutMs)Set connect timeout on socket.voidsetSocketReceiveTimeout(int timeoutMs)Set receive timeout on socket.voidsetTcpNoDelay(boolean enabled)Set TCP No-Delay ("Nagle") for TCP connection.voidsetTLSEnabledProtocols(java.lang.String[] protocols)Set TLS enabled protocols.voidsetValidateIncomingUtf8(boolean enabled)Controls whether incoming text message payload is verified to be valid UTF-8.
-
-
-
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()
-
-