Class JettyWebSocketServerContainer
- All Implemented Interfaces:
EventListener, WebSocketContainer, WebSocketPolicy, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, LifeCycle.Listener
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMapping(String pathSpec, Class<?> endpointClass) voidaddMapping(String pathSpec, JettyWebSocketCreator creator) voidaddSessionListener(WebSocketSessionListener listener) Register a WebSocketSessionListener with the containervoiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.ensureContainer(javax.servlet.ServletContext servletContext) getContainer(javax.servlet.ServletContext servletContext) The Container provided Executor.The duration that a websocket may be idle before being closed by the implementationintThe input (read from network layer) buffer size.longGet the maximum size of a binary message during parsing.longThe maximum payload size of any WebSocket Frame which can be received.longGet the maximum size of a text message during parsing.Get the collection of open Sessions being tracked by this containerintThe output (write to network layer) buffer size.booleanIf true, frames are automatically fragmented to respect the maximum frame size.voidNotify the Session Listeners of an event.booleanRemove a WebSocketSessionListener from the containervoidsetAutoFragment(boolean autoFragment) If set to true, frames are automatically fragmented to respect the maximum frame size.voidsetIdleTimeout(Duration duration) The duration that a websocket may be idle before being closed by the implementationvoidsetInputBufferSize(int size) The input (read from network layer) buffer size.voidsetMaxBinaryMessageSize(long size) The maximum size of a binary message during parsing/generating.voidsetMaxFrameSize(long maxFrameSize) The maximum payload size of any WebSocket Frame which can be received.voidsetMaxTextMessageSize(long size) The maximum size of a text message during parsing/generating.voidsetOutputBufferSize(int size) The output (write to network layer) buffer size.booleanupgrade(JettyWebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) An immediate programmatic WebSocket upgrade that does not register a mapping or create aWebSocketUpgradeFilter.Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface LifeCycle.Listener
lifeCycleFailure, lifeCycleStarted, lifeCycleStarting, lifeCycleStopped, lifeCycleStopping
-
Field Details
-
JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE
-
-
Method Details
-
getContainer
public static JettyWebSocketServerContainer getContainer(javax.servlet.ServletContext servletContext) -
ensureContainer
public static JettyWebSocketServerContainer ensureContainer(javax.servlet.ServletContext servletContext) -
addMapping
-
addMapping
-
upgrade
public boolean upgrade(JettyWebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException An immediate programmatic WebSocket upgrade that does not register a mapping or create aWebSocketUpgradeFilter.A return value of true means the connection was Upgraded to WebSocket or an error response is being generated. A return value of false means that it was a bad upgrade request and couldn't be upgraded to WebSocket and the caller is responsible for generating the response.
- Parameters:
creator- the WebSocketCreator to use.request- the HttpServletRequest.response- the HttpServletResponse.- Returns:
- true if the connection could be upgraded or an error was sent.
- Throws:
IOException- if an I/O error occurs.
-
getExecutor
Description copied from interface:WebSocketContainerThe Container provided Executor.- Specified by:
getExecutorin interfaceWebSocketContainer
-
addSessionListener
Description copied from interface:WebSocketContainerRegister a WebSocketSessionListener with the container- Specified by:
addSessionListenerin interfaceWebSocketContainer- Parameters:
listener- the listener
-
removeSessionListener
Description copied from interface:WebSocketContainerRemove a WebSocketSessionListener from the container- Specified by:
removeSessionListenerin interfaceWebSocketContainer- Parameters:
listener- the listener- Returns:
- true if listener was present and removed
-
notifySessionListeners
Description copied from interface:WebSocketContainerNotify the Session Listeners of an event.- Specified by:
notifySessionListenersin interfaceWebSocketContainer- Parameters:
consumer- the consumer to call for each tracked listener
-
getOpenSessions
Description copied from interface:WebSocketContainerGet the collection of open Sessions being tracked by this container- Specified by:
getOpenSessionsin interfaceWebSocketContainer- Returns:
- the collection of open sessions
-
getBehavior
- Specified by:
getBehaviorin interfaceWebSocketPolicy
-
getIdleTimeout
Description copied from interface:WebSocketPolicyThe duration that a websocket may be idle before being closed by the implementation- Specified by:
getIdleTimeoutin interfaceWebSocketPolicy- Returns:
- the timeout duration
-
getInputBufferSize
public int getInputBufferSize()Description copied from interface:WebSocketPolicyThe input (read from network layer) buffer size.This is the raw read operation buffer size, before the parsing of the websocket frames.
- Specified by:
getInputBufferSizein interfaceWebSocketPolicy- Returns:
- the raw network buffer input size.
-
getOutputBufferSize
public int getOutputBufferSize()Description copied from interface:WebSocketPolicyThe output (write to network layer) buffer size.This is the raw write operation buffer size and has no relationship to the websocket frame.
- Specified by:
getOutputBufferSizein interfaceWebSocketPolicy- Returns:
- the raw network buffer output size.
-
getMaxBinaryMessageSize
public long getMaxBinaryMessageSize()Description copied from interface:WebSocketPolicyGet 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- Specified by:
getMaxBinaryMessageSizein interfaceWebSocketPolicy- Returns:
- the maximum size of a binary message
-
getMaxTextMessageSize
public long getMaxTextMessageSize()Description copied from interface:WebSocketPolicyGet 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- Specified by:
getMaxTextMessageSizein interfaceWebSocketPolicy- Returns:
- the maximum size of a text message.
-
getMaxFrameSize
public long getMaxFrameSize()Description copied from interface:WebSocketPolicyThe maximum payload size of any WebSocket Frame which can be received.- Specified by:
getMaxFrameSizein interfaceWebSocketPolicy- Returns:
- the maximum size of a WebSocket Frame.
-
isAutoFragment
public boolean isAutoFragment()Description copied from interface:WebSocketPolicyIf true, frames are automatically fragmented to respect the maximum frame size.- Specified by:
isAutoFragmentin interfaceWebSocketPolicy- Returns:
- whether to automatically fragment incoming WebSocket Frames.
-
setIdleTimeout
Description copied from interface:WebSocketPolicyThe duration that a websocket may be idle before being closed by the implementation- Specified by:
setIdleTimeoutin interfaceWebSocketPolicy- Parameters:
duration- the timeout duration (may not be null or negative)
-
setInputBufferSize
public void setInputBufferSize(int size) Description copied from interface:WebSocketPolicyThe input (read from network layer) buffer size.- Specified by:
setInputBufferSizein interfaceWebSocketPolicy- Parameters:
size- the size in bytes
-
setOutputBufferSize
public void setOutputBufferSize(int size) Description copied from interface:WebSocketPolicyThe output (write to network layer) buffer size.- Specified by:
setOutputBufferSizein interfaceWebSocketPolicy- Parameters:
size- the size in bytes
-
setMaxBinaryMessageSize
public void setMaxBinaryMessageSize(long size) Description copied from interface:WebSocketPolicyThe 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- Specified by:
setMaxBinaryMessageSizein interfaceWebSocketPolicy- Parameters:
size- the maximum allowed size of a binary message.
-
setMaxTextMessageSize
public void setMaxTextMessageSize(long size) Description copied from interface:WebSocketPolicyThe 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- Specified by:
setMaxTextMessageSizein interfaceWebSocketPolicy- Parameters:
size- the maximum allowed size of a text message.
-
setMaxFrameSize
public void setMaxFrameSize(long maxFrameSize) Description copied from interface:WebSocketPolicyThe maximum payload size of any WebSocket Frame which can be received.WebSocket Frames over this maximum will result in a close code 1009
StatusCode.MESSAGE_TOO_LARGE- Specified by:
setMaxFrameSizein interfaceWebSocketPolicy- Parameters:
maxFrameSize- the maximum allowed size of a WebSocket Frame.
-
setAutoFragment
public void setAutoFragment(boolean autoFragment) Description copied from interface:WebSocketPolicyIf set to true, frames are automatically fragmented to respect the maximum frame size.- Specified by:
setAutoFragmentin interfaceWebSocketPolicy- Parameters:
autoFragment- whether to automatically fragment incoming WebSocket Frames.
-
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Overrides:
dumpin classContainerLifeCycle- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-