Class WebSocketPolicy
- java.lang.Object
-
- org.eclipse.jetty.websocket.api.WebSocketPolicy
-
- Direct Known Subclasses:
WebSocketPolicy.Delegated
public class WebSocketPolicy extends java.lang.Object
Settings for WebSocket operations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
WebSocketPolicy.Delegated
Allows Behavior to be changed, but the settings to delegated.
-
Field Summary
Fields Modifier and Type Field Description private long
asyncWriteTimeout
The timeout in ms (milliseconds) for async write operations.private WebSocketBehavior
behavior
Behavior of the websocketsprivate long
idleTimeout
The time in ms (milliseconds) that a websocket may be idle before closing.private int
inputBufferSize
The size of the input (read from network layer) buffer size.private static int
KB
private int
maxBinaryMessageBufferSize
The maximum size of a binary message bufferprivate int
maxBinaryMessageSize
The maximum size of a binary message during parsing/generating.private int
maxTextMessageBufferSize
The maximum size of a text message buffer.private int
maxTextMessageSize
The maximum size of a text message during parsing/generating.
-
Constructor Summary
Constructors Constructor Description WebSocketPolicy(WebSocketBehavior behavior)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
assertGreaterThan(java.lang.String name, long size, long minSize)
private void
assertLessThan(java.lang.String name, long size, java.lang.String otherName, long otherSize)
void
assertValidBinaryMessageSize(int requestedSize)
void
assertValidTextMessageSize(int requestedSize)
WebSocketPolicy
clonePolicy()
Make a copy of the policy, with current values.WebSocketPolicy
clonePolicy(WebSocketBehavior behavior)
Deprecated.usedelegateAs(WebSocketBehavior)
insteadWebSocketPolicy
delegateAs(WebSocketBehavior behavior)
long
getAsyncWriteTimeout()
Deprecated.WebSocketBehavior
getBehavior()
long
getIdleTimeout()
The time in ms (milliseconds) that a websocket connection may be idle before being closed automatically.int
getInputBufferSize()
The size of the input (read from network layer) buffer size.int
getMaxBinaryMessageBufferSize()
Get the maximum size of a binary message buffer (for streaming writing)int
getMaxBinaryMessageSize()
Get the maximum size of a binary message during parsing.int
getMaxTextMessageBufferSize()
Get the maximum size of a text message buffer (for streaming writing)int
getMaxTextMessageSize()
Get the maximum size of a text message during parsing.static WebSocketPolicy
newClientPolicy()
static WebSocketPolicy
newServerPolicy()
void
setAsyncWriteTimeout(long ms)
The timeout in ms (milliseconds) for async write operations.void
setIdleTimeout(long ms)
The time in ms (milliseconds) that a websocket may be idle before closing.void
setInputBufferSize(int size)
The size of the input (read from network layer) buffer size.void
setMaxBinaryMessageBufferSize(int size)
The maximum size of a binary message buffer.void
setMaxBinaryMessageSize(int size)
The maximum size of a binary message during parsing.void
setMaxTextMessageBufferSize(int size)
The maximum size of a text message buffer.void
setMaxTextMessageSize(int size)
The maximum size of a text message during parsing.java.lang.String
toString()
-
-
-
Field Detail
-
KB
private static final int KB
- See Also:
- Constant Field Values
-
maxTextMessageSize
private int maxTextMessageSize
The maximum size of a text message during parsing/generating.Text messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
Default: 65536 (64 K)
-
maxTextMessageBufferSize
private int maxTextMessageBufferSize
The maximum size of a text message buffer.Used ONLY for stream based message writing.
Default: 32768 (32 K)
-
maxBinaryMessageSize
private int maxBinaryMessageSize
The maximum size of a binary message during parsing/generating.Binary messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
Default: 65536 (64 K)
-
maxBinaryMessageBufferSize
private int maxBinaryMessageBufferSize
The maximum size of a binary message bufferUsed ONLY for for stream based message writing
Default: 32768 (32 K)
-
asyncWriteTimeout
private long asyncWriteTimeout
The timeout in ms (milliseconds) for async write operations.Negative values indicate a disabled timeout.
-
idleTimeout
private long idleTimeout
The time in ms (milliseconds) that a websocket may be idle before closing.Default: 300000 (ms)
-
inputBufferSize
private int inputBufferSize
The size of the input (read from network layer) buffer size.Default: 4096 (4 K)
-
behavior
private final WebSocketBehavior behavior
Behavior of the websockets
-
-
Constructor Detail
-
WebSocketPolicy
public WebSocketPolicy(WebSocketBehavior behavior)
-
-
Method Detail
-
newClientPolicy
public static WebSocketPolicy newClientPolicy()
-
newServerPolicy
public static WebSocketPolicy newServerPolicy()
-
assertLessThan
private void assertLessThan(java.lang.String name, long size, java.lang.String otherName, long otherSize)
-
assertGreaterThan
private void assertGreaterThan(java.lang.String name, long size, long minSize)
-
assertValidBinaryMessageSize
public void assertValidBinaryMessageSize(int requestedSize)
-
assertValidTextMessageSize
public void assertValidTextMessageSize(int requestedSize)
-
clonePolicy
public WebSocketPolicy clonePolicy()
Make a copy of the policy, with current values.- Returns:
- the cloned copy of the policy.
-
clonePolicy
@Deprecated public WebSocketPolicy clonePolicy(WebSocketBehavior behavior)
Deprecated.usedelegateAs(WebSocketBehavior)
insteadMake a copy of the policy, with current values, but a different behavior.- Parameters:
behavior
- the behavior to copy/clone- Returns:
- the cloned policy with a new behavior.
-
delegateAs
public WebSocketPolicy delegateAs(WebSocketBehavior behavior)
-
getAsyncWriteTimeout
@Deprecated public long getAsyncWriteTimeout()
Deprecated.The timeout in ms (milliseconds) for async write operations.Negative values indicate a disabled timeout.
- Returns:
- the timeout for async write operations. negative values indicate disabled timeout.
-
getBehavior
public WebSocketBehavior getBehavior()
-
getIdleTimeout
public long getIdleTimeout()
The time in ms (milliseconds) that a websocket connection may be idle before being closed automatically.- Returns:
- the timeout in milliseconds for idle timeout.
-
getInputBufferSize
public int getInputBufferSize()
The size of the input (read from network layer) buffer size.This is the raw read operation buffer size, before the parsing of the websocket frames.
- Returns:
- the raw network bytes read operation buffer size.
-
getMaxBinaryMessageBufferSize
public int getMaxBinaryMessageBufferSize()
Get the maximum size of a binary message buffer (for streaming writing)- Returns:
- the maximum size of a binary message buffer
-
getMaxBinaryMessageSize
public int getMaxBinaryMessageSize()
Get the maximum size of a binary message during parsing.This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling binary messages. This applies to individual frames, whole message handling, and partial message handling.
Binary messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
- Returns:
- the maximum size of a binary message
-
getMaxTextMessageBufferSize
public int getMaxTextMessageBufferSize()
Get the maximum size of a text message buffer (for streaming writing)- Returns:
- the maximum size of a text message buffer
-
getMaxTextMessageSize
public int getMaxTextMessageSize()
Get the maximum size of a text message during parsing.This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling text messages. This applies to individual frames, whole message handling, and partial message handling.
Text messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
- Returns:
- the maximum size of a text message.
-
setAsyncWriteTimeout
public void setAsyncWriteTimeout(long ms)
The timeout in ms (milliseconds) for async write operations.Negative values indicate a disabled timeout.
- Parameters:
ms
- the timeout in milliseconds
-
setIdleTimeout
public void setIdleTimeout(long ms)
The time in ms (milliseconds) that a websocket may be idle before closing.- Parameters:
ms
- the timeout in milliseconds
-
setInputBufferSize
public void setInputBufferSize(int size)
The size of the input (read from network layer) buffer size.- Parameters:
size
- the size in bytes
-
setMaxBinaryMessageBufferSize
public void setMaxBinaryMessageBufferSize(int size)
The maximum size of a binary message buffer.Used ONLY for stream based binary message writing.
- Parameters:
size
- the maximum size of the binary message buffer
-
setMaxBinaryMessageSize
public void setMaxBinaryMessageSize(int size)
The maximum size of a binary message during parsing.This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling binary messages. This applies to individual frames, whole message handling, and partial message handling.
Binary messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
- Parameters:
size
- the maximum allowed size of a binary message.
-
setMaxTextMessageBufferSize
public void setMaxTextMessageBufferSize(int size)
The maximum size of a text message buffer.Used ONLY for stream based text message writing.
- Parameters:
size
- the maximum size of the text message buffer
-
setMaxTextMessageSize
public void setMaxTextMessageSize(int size)
The maximum size of a text message during parsing.This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling text messages. This applies to individual frames, whole message handling, and partial message handling.
Text messages over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE
- Parameters:
size
- the maximum allowed size of a text message.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-