Class WebSocketSession
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.websocket.common.WebSocketSession
- All Implemented Interfaces:
Closeable, AutoCloseable, org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, IncomingFrames, OutgoingFrames, Session, RemoteEndpointFactory, WebSocketSessionScope
- Direct Known Subclasses:
JsrSession
@ManagedObject("A Jetty WebSocket Session")
public class WebSocketSession
extends org.eclipse.jetty.util.component.ContainerLifeCycle
implements Session, RemoteEndpointFactory, WebSocketSessionScope, IncomingFrames, OutgoingFrames, org.eclipse.jetty.io.Connection.Listener
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection.Listener
org.eclipse.jetty.io.Connection.Listener.AdapterNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassLoaderprivate final LogicalConnectionprivate final WebSocketContainerScopeprivate static final RemoteEndpointFactoryprivate final Executorprivate ExtensionFactoryprivate final IncomingFramesprivate static final org.eclipse.jetty.util.log.Loggerprivate final AtomicBooleanprivate CompletableFuture<Session> private OutgoingFramesprivate final WebSocketPolicyprivate Stringprivate RemoteEndpointprivate final RemoteEndpointFactoryprivate final URIprivate UpgradeRequestprivate UpgradeResponseprivate final EventDriverFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketSession(WebSocketContainerScope containerScope, URI requestURI, EventDriver websocket, LogicalConnection connection) -
Method Summary
Modifier and TypeMethodDescriptionvoidcallApplicationOnClose(CloseInfo closeInfo) voidcallApplicationOnError(Throwable cause) voidclose()Request a close of the current conversation with a normal status code and no reason phrase.voidSend a websocket Close frame, with status code.voidClose the active session based on the throwablevoidclose(CloseStatus closeStatus) Request Close the current conversation, giving a reason for the closure.private voidClose Primary Entry Point.voidHarsh disconnectvoidprotected voiddoStart()protected voiddoStop()dumpSelf()org.eclipse.jetty.io.ByteBufferPoolThe parentWebSocketContainerScopefor this session scope.longThe idle timeout in millisecondsGet the address of the local side.Access the (now read-only)WebSocketPolicyin use for this connection.Returns the version of the websocket protocol currently being used.Return a reference to the RemoteEndpoint object representing the other end of this conversation.Get the address of the remote side.Get the UpgradeRequest used to create this sessionGet the UpgradeResponse used to create this sessionActiveWebSocketSessionassociated with this scope.voidincomingFrame(Frame frame) Incoming Raw Frames from ParserbooleanisOpen()Return true if and only if the underlying socket is open.booleanisSecure()Return true if and only if the underlying socket is using a secure transport.newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode) private voidnotifySessionListeners(WebSocketContainerScope scope, Consumer<WebSocketSessionListener> consumer) voidonClosed(org.eclipse.jetty.io.Connection connection) Jetty Connection onSessionClosed eventvoidonOpened(org.eclipse.jetty.io.Connection connection) Jetty Connection onOpen eventvoidopen()Open/Activate the sessionvoidoutgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode) A frame, and optional callback, intended for the network layer.voidsetExtensionFactory(ExtensionFactory extensionFactory) voidvoidsetIdleTimeout(long ms) Set the timeout in millisecondsvoidsetOutgoingHandler(OutgoingFrames outgoing) voidsetPolicy(WebSocketPolicy policy) Deprecated.voidsetUpgradeRequest(UpgradeRequest request) voidsetUpgradeResponse(UpgradeResponse response) suspend()Suspend the incoming read events on the connection.toString()Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Field Details
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
defaultRemoteEndpointFactory
-
containerScope
-
requestURI
-
connection
-
websocket
-
executor
-
policy
-
onCloseCalled
-
remoteEndpointFactory
-
classLoader
-
extensionFactory
-
protocolVersion
-
parameterMap
-
remote
-
incomingHandler
-
outgoingHandler
-
upgradeRequest
-
upgradeResponse
-
openFuture
-
-
Constructor Details
-
WebSocketSession
public WebSocketSession(WebSocketContainerScope containerScope, URI requestURI, EventDriver websocket, LogicalConnection connection)
-
-
Method Details
-
close
Close the active session based on the throwable- Parameters:
cause- the cause for closing the connection
-
close
public void close()Description copied from interface:SessionRequest a close of the current conversation with a normal status code and no reason phrase.This will enqueue a graceful close to the remote endpoint.
-
close
Description copied from interface:SessionRequest Close the current conversation, giving a reason for the closure. Note the websocket spec defines the acceptable uses of status codes and reason phrases.This will enqueue a graceful close to the remote endpoint.
-
close
Description copied from interface:SessionSend a websocket Close frame, with status code.This will enqueue a graceful close to the remote endpoint.
-
close
Close Primary Entry Point.- Parameters:
closeInfo- the close details
-
disconnect
-
dispatch
-
doStart
-
doStop
-
dumpSelf
- Specified by:
dumpSelfin interfaceorg.eclipse.jetty.util.component.Dumpable
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool() -
getClassLoader
-
getConnection
-
getContainerScope
Description copied from interface:WebSocketSessionScopeThe parentWebSocketContainerScopefor this session scope.- Specified by:
getContainerScopein interfaceWebSocketSessionScope- Returns:
- the websocket container scope
-
getExtensionFactory
-
getIdleTimeout
public long getIdleTimeout()The idle timeout in milliseconds- Specified by:
getIdleTimeoutin interfaceSession- Returns:
- the timeout in milliseconds.
-
getIncomingHandler
-
getLocalAddress
Description copied from interface:SessionGet the address of the local side.- Specified by:
getLocalAddressin interfaceSession- Returns:
- the local side address
-
getOutgoingHandler
-
getPolicy
Description copied from interface:SessionAccess the (now read-only)WebSocketPolicyin use for this connection. -
getProtocolVersion
Description copied from interface:SessionReturns the version of the websocket protocol currently being used. This is taken as the value of the Sec-WebSocket-Version header used in the opening handshake. i.e. "13".- Specified by:
getProtocolVersionin interfaceSession- Returns:
- the protocol version
-
getRemote
Description copied from interface:SessionReturn a reference to the RemoteEndpoint object representing the other end of this conversation. -
getRemoteAddress
Description copied from interface:SessionGet the address of the remote side.- Specified by:
getRemoteAddressin interfaceSession- Returns:
- the remote side address
-
getRequestURI
-
getUpgradeRequest
Description copied from interface:SessionGet the UpgradeRequest used to create this session- Specified by:
getUpgradeRequestin interfaceSession- Returns:
- the UpgradeRequest used to create this session
-
getUpgradeResponse
Description copied from interface:SessionGet the UpgradeResponse used to create this session- Specified by:
getUpgradeResponsein interfaceSession- Returns:
- the UpgradeResponse used to create this session
-
getWebSocketSession
Description copied from interface:WebSocketSessionScopeActiveWebSocketSessionassociated with this scope.- Specified by:
getWebSocketSessionin interfaceWebSocketSessionScope- Returns:
- the websocket session
-
incomingFrame
Incoming Raw Frames from Parser- Specified by:
incomingFramein interfaceIncomingFrames- Parameters:
frame- the frame to process
-
outgoingFrame
Description copied from interface:OutgoingFramesA frame, and optional callback, intended for the network layer.Note: the frame can undergo many transformations in the various layers and extensions present in the implementation.
If you are implementing a mutation, you are obliged to handle the incoming WriteCallback appropriately.
- Specified by:
outgoingFramein interfaceOutgoingFrames- Parameters:
frame- the frame to eventually write to the network layer.callback- the callback to notify when the frame is written.batchMode- the batch mode requested by the sender.
-
isOpen
-
isSecure
-
callApplicationOnClose
-
callApplicationOnError
-
onClosed
public void onClosed(org.eclipse.jetty.io.Connection connection) Jetty Connection onSessionClosed event- Specified by:
onClosedin interfaceorg.eclipse.jetty.io.Connection.Listener- Parameters:
connection- the connection that was closed
-
onOpened
public void onOpened(org.eclipse.jetty.io.Connection connection) Jetty Connection onOpen event- Specified by:
onOpenedin interfaceorg.eclipse.jetty.io.Connection.Listener- Parameters:
connection- the connection that was opened
-
newRemoteEndpoint
public WebSocketRemoteEndpoint newRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode) - Specified by:
newRemoteEndpointin interfaceRemoteEndpointFactory
-
open
public void open()Open/Activate the session -
setExtensionFactory
-
setFuture
-
setIdleTimeout
public void setIdleTimeout(long ms) Set the timeout in milliseconds- Specified by:
setIdleTimeoutin interfaceSession- Parameters:
ms- the number of milliseconds.
-
setOutgoingHandler
-
setPolicy
Deprecated. -
setUpgradeRequest
-
setUpgradeResponse
-
suspend
Description copied from interface:SessionSuspend the incoming read events on the connection. -
getBatchMode
- Returns:
- the default (initial) value for the batching mode.
-
notifySessionListeners
private void notifySessionListeners(WebSocketContainerScope scope, Consumer<WebSocketSessionListener> consumer) -
toString
- Overrides:
toStringin classorg.eclipse.jetty.util.component.AbstractLifeCycle
-