A server-side WebSocket container that allows to map
URI paths to WebSocket endpoints and configure WebSocket parameters such as idle timeouts,
max WebSocket message sizes, etc.
Direct WebSocket upgrades not mapped to URI paths are possible via
upgrade(WebSocketCreator, Request, Response, Callback).
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ServerWebSocketContainer. | |
| private final FrameHandlerFactory | |
| private Invocable. | |
| private final List | |
| private static final Logger | |
| private final WebSocketMappings | |
| private final SessionTracker |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | addMapping(String
the pathSpec, WebSocketCreator pathSpec to associate to the creatorthe creator of WebSocket endpoints creator)Maps the given |
| public void | addMapping(PathSpec
the pathSpec, WebSocketCreator pathSpec to associate to the creatorthe creator of WebSocket endpoints creator)Maps the given |
| public void | addSessionListener(WebSocketSessionListener
the listener listener)Implements org. Register a WebSocketSessionListener with the container |
| public static ServerWebSocketContainer | ensure(Server
the server, ContextHandler Server object used to lookup common WebSocket componentsthe contextHandler)ContextHandler used to store the ServerWebSocketContainerReturns the |
| public static ServerWebSocketContainer | Returns: theServerWebSocketContainer stored as an attribute,
or null if no such attribute is presentthe context)Context to look for the attributeReturns the |
| public Executor | getExecutor()
Implements org. The Container provided Executor. |
| public Duration | getIdleTimeout()
Implements org. The duration that a websocket may be idle before being closed by the implementation |
| public int | getInputBufferSize()
Implements org. The input (read from network layer) buffer size. |
| public Invocable. | getInvocationType()
Overrides default org. Returns: the invocation type, typically blocking or non-blocking, of this container |
| public long | getMaxBinaryMessageSize()
Implements org. Get the maximum size of a binary message during parsing. |
| public long | getMaxFrameSize()
Implements org. The maximum payload size of any WebSocket Frame which can be received. |
| public int | getMaxOutgoingFrames()
Implements org. Get the maximum number of data frames allowed to be waiting to be sent at any one time. |
| public long | getMaxTextMessageSize()
Implements org. Get the maximum size of a text message during parsing. |
| public Collection | getOpenSessions()
Implements org. Get the collection of open Sessions being tracked by this container |
| public int | getOutputBufferSize()
Implements org. The output (write to network layer) buffer size. |
| public boolean | Returns: true in case of WebSocket upgrades or failures,
false if the request was not handledthe request to handle, possibly a WebSocket upgrade request request, Response the response to handle response, Callback the callback to complete when the handling is complete callback)Implements org. Matches the given |
| public boolean | isAutoFragment()
Implements org. If true, frames are automatically fragmented to respect the maximum frame size. |
| private WebSocketCreator | |
| public void | notifySessionListeners(Consumer<WebSocketSessionListener>
the consumer to call for each tracked listener consumer)Implements org. Notify the Session Listeners of an event. |
| public boolean | removeSessionListener(WebSocketSessionListener
the listener listener)Implements org. Remove a WebSocketSessionListener from the container |
| public void | setAutoFragment(boolean
whether to automatically fragment incoming WebSocket Frames. autoFragment)Implements org. If set to true, frames are automatically fragmented to respect the maximum frame size. |
| public void | setIdleTimeout(Duration
the timeout duration (may not be null or negative) duration)Implements org. The duration that a websocket may be idle before being closed by the implementation |
| public void | setInputBufferSize(int
the size in bytes size)Implements org. The input (read from network layer) buffer size. |
| public void | setInvocationType(Invocable.
the invocation type of this container invocationTypeSets the invocation type of this container. |
| public void | setMaxBinaryMessageSize(long
the maximum allowed size of a binary message. size)Implements org. The maximum size of a binary message during parsing/generating. |
| public void | setMaxFrameSize(long
the maximum allowed size of a WebSocket Frame. maxFrameSize)Implements org. The maximum payload size of any WebSocket Frame which can be received. |
| public void | setMaxOutgoingFrames(int
the max number of frames. maxOutgoingFrames)Implements org. Set the maximum number of data frames allowed to be waiting to be sent at any one time. |
| public void | setMaxTextMessageSize(long
the maximum allowed size of a text message. size)Implements org. The maximum size of a text message during parsing/generating. |
| public void | setOutputBufferSize(int
the size in bytes size)Implements org. The output (write to network layer) buffer size. |
| public boolean | Returns: true in case of WebSocket upgrades or failures,
false if the request was not upgradedthe creator of the WebSocket endpoint creator, Request the request to upgrade, possibly a WebSocket upgrade request request, Response the response response, Callback the callback to complete when the upgrade is complete callback)Upgrades the given |
| configuration | back to summary |
|---|---|
| private final ServerWebSocketContainer. | |
| factory | back to summary |
|---|---|
| private final FrameHandlerFactory factory | |
| invocationType | back to summary |
|---|---|
| private Invocable. | |
| listeners | back to summary |
|---|---|
| private final List<WebSocketSessionListener> listeners | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG Hides org. | |
| mappings | back to summary |
|---|---|
| private final WebSocketMappings mappings | |
| sessionTracker | back to summary |
|---|---|
| private final SessionTracker sessionTracker | |
| ServerWebSocketContainer | back to summary |
|---|---|
| pack-priv ServerWebSocketContainer(WebSocketMappings mappings) | |
| addMapping | back to summary |
|---|---|
| public void addMapping(String pathSpec, WebSocketCreator creator) Maps the given The
| |
| addMapping | back to summary |
|---|---|
| public void addMapping(PathSpec pathSpec, WebSocketCreator creator) Maps the given
| |
| addSessionListener | back to summary |
|---|---|
| public void addSessionListener(WebSocketSessionListener listener) Implements org. Doc from org. Register a WebSocketSessionListener with the container
| |
| ensure | back to summary |
|---|---|
| public static ServerWebSocketContainer ensure(Server server, ContextHandler contextHandler) Returns the If the This method should be invoked during the setup of the
| |
| get | back to summary |
|---|---|
| public static ServerWebSocketContainer get(Context context) Returns the
| |
| getExecutor | back to summary |
|---|---|
| public Executor getExecutor() Implements org. Doc from org. The Container provided Executor.
| |
| getIdleTimeout | back to summary |
|---|---|
| public Duration getIdleTimeout() Implements org. Doc from org. The duration that a websocket may be idle before being closed by the implementation | |
| getInputBufferSize | back to summary |
|---|---|
| public int getInputBufferSize() Implements org. Doc from org. The input (read from network layer) buffer size. This is the raw read operation buffer size, before the parsing of the websocket frames.
| |
| getInvocationType | back to summary |
|---|---|
| public Invocable. Overrides default org.
| |
| getMaxBinaryMessageSize | back to summary |
|---|---|
| public long getMaxBinaryMessageSize() Implements org. Doc from org. 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
| |
| getMaxFrameSize | back to summary |
|---|---|
| public long getMaxFrameSize() Implements org. Doc from org. The maximum payload size of any WebSocket Frame which can be received.
| |
| getMaxOutgoingFrames | back to summary |
|---|---|
| public int getMaxOutgoingFrames() Implements org. Doc from org. Get the maximum number of data frames allowed to be waiting to be sent at any one time.
The default value is -1, this indicates there is no limit on how many frames can be
queued to be sent by the implementation. If the limit is exceeded, subsequent frames
sent are failed with a
| |
| getMaxTextMessageSize | back to summary |
|---|---|
| public long getMaxTextMessageSize() Implements org. Doc from org. 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
| |
| getOpenSessions | back to summary |
|---|---|
| public Collection Implements org. Doc from org. Get the collection of open Sessions being tracked by this container
| |
| getOutputBufferSize | back to summary |
|---|---|
| public int getOutputBufferSize() Implements org. Doc from org. The output (write to network layer) buffer size. This is the raw write operation buffer size and has no relationship to the websocket frame.
| |
| handle | back to summary |
|---|---|
| public boolean handle(Request request, Response response, Callback callback) throws WebSocketException Implements org. Matches the given Direct upgrades without using WebSocket mappings may be performed via
When When
| |
| isAutoFragment | back to summary |
|---|---|
| public boolean isAutoFragment() Implements org. Doc from org. If true, frames are automatically fragmented to respect the maximum frame size.
| |
| newWebSocketCreator | back to summary |
|---|---|
| private WebSocketCreator newWebSocketCreator(WebSocketCreator creator) | |
| notifySessionListeners | back to summary |
|---|---|
| public void notifySessionListeners(Consumer<WebSocketSessionListener> consumer) Implements org. Doc from org. Notify the Session Listeners of an event.
| |
| removeSessionListener | back to summary |
|---|---|
| public boolean removeSessionListener(WebSocketSessionListener listener) Implements org. Doc from org. Remove a WebSocketSessionListener from the container
| |
| setAutoFragment | back to summary |
|---|---|
| public void setAutoFragment(boolean autoFragment) Implements org. Doc from org. If set to true, frames are automatically fragmented to respect the maximum frame size.
| |
| setIdleTimeout | back to summary |
|---|---|
| public void setIdleTimeout(Duration duration) Implements org. Doc from org. The duration that a websocket may be idle before being closed by the implementation | |
| setInputBufferSize | back to summary |
|---|---|
| public void setInputBufferSize(int size) Implements org. Doc from org. The input (read from network layer) buffer size.
| |
| setInvocationType | back to summary |
|---|---|
| public void setInvocationType(Invocable. Sets the invocation type of this container. The invocation type may be set to Setting the invocation type to By default
| |
| setMaxBinaryMessageSize | back to summary |
|---|---|
| public void setMaxBinaryMessageSize(long size) Implements org. Doc from org. The maximum size of a binary message during parsing/generating.
Binary messages over this maximum will result in a close code 1009
| |
| setMaxFrameSize | back to summary |
|---|---|
| public void setMaxFrameSize(long maxFrameSize) Implements org. Doc from org. The maximum payload size of any WebSocket Frame which can be received.
WebSocket Frames over this maximum will result in a close code 1009
| |
| setMaxOutgoingFrames | back to summary |
|---|---|
| public void setMaxOutgoingFrames(int maxOutgoingFrames) Implements org. Doc from org. Set the maximum number of data frames allowed to be waiting to be sent at any one time.
The default value is -1, this indicates there is no limit on how many frames can be
queued to be sent by the implementation. If the limit is exceeded, subsequent frames
sent are failed with a
| |
| setMaxTextMessageSize | back to summary |
|---|---|
| public void setMaxTextMessageSize(long size) Implements org. Doc from org. The maximum size of a text message during parsing/generating.
Text messages over this maximum will result in a close code 1009
| |
| setOutputBufferSize | back to summary |
|---|---|
| public void setOutputBufferSize(int size) Implements org. Doc from org. The output (write to network layer) buffer size.
| |
| upgrade | back to summary |
|---|---|
| public boolean upgrade(WebSocketCreator creator, Request request, Response response, Callback callback) throws WebSocketException Upgrades the given When When
| |
| Access | Constructor and Description |
|---|---|
| private |
| Configuration | back to summary |
|---|---|
| private Configuration() | |