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.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection.Listener
org.eclipse.jetty.io.Connection.Listener.Adapter
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassLoader
private final LogicalConnection
private final WebSocketContainerScope
private static final RemoteEndpointFactory
private final Executor
private ExtensionFactory
private final IncomingFrames
private static final org.eclipse.jetty.util.log.Logger
private final AtomicBoolean
private CompletableFuture<Session>
private OutgoingFrames
private final WebSocketPolicy
private String
private RemoteEndpoint
private final RemoteEndpointFactory
private final URI
private UpgradeRequest
private UpgradeResponse
private final EventDriver
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Fields 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 TypeMethodDescriptionvoid
callApplicationOnClose
(CloseInfo closeInfo) void
callApplicationOnError
(Throwable cause) void
close()
Request a close of the current conversation with a normal status code and no reason phrase.void
Send a websocket Close frame, with status code.void
Close the active session based on the throwablevoid
close
(CloseStatus closeStatus) Request Close the current conversation, giving a reason for the closure.private void
Close Primary Entry Point.void
Harsh disconnectvoid
protected void
doStart()
protected void
doStop()
dumpSelf()
org.eclipse.jetty.io.ByteBufferPool
The parentWebSocketContainerScope
for this session scope.long
The idle timeout in millisecondsGet the address of the local side.Access the (now read-only)WebSocketPolicy
in 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 sessionActiveWebSocketSession
associated with this scope.void
incomingFrame
(Frame frame) Incoming Raw Frames from Parserboolean
isOpen()
Return true if and only if the underlying socket is open.boolean
isSecure()
Return true if and only if the underlying socket is using a secure transport.newRemoteEndpoint
(LogicalConnection connection, OutgoingFrames outgoingFrames, BatchMode batchMode) private void
notifySessionListeners
(WebSocketContainerScope scope, Consumer<WebSocketSessionListener> consumer) void
onClosed
(org.eclipse.jetty.io.Connection connection) Jetty Connection onSessionClosed eventvoid
onOpened
(org.eclipse.jetty.io.Connection connection) Jetty Connection onOpen eventvoid
open()
Open/Activate the sessionvoid
outgoingFrame
(Frame frame, WriteCallback callback, BatchMode batchMode) A frame, and optional callback, intended for the network layer.void
setExtensionFactory
(ExtensionFactory extensionFactory) void
void
setIdleTimeout
(long ms) Set the timeout in millisecondsvoid
setOutgoingHandler
(OutgoingFrames outgoing) void
setPolicy
(WebSocketPolicy policy) Deprecated.void
setUpgradeRequest
(UpgradeRequest request) void
setUpgradeResponse
(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, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:Session
Request 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:Session
Request 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:Session
Send 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
public void disconnect()Harsh disconnect- Specified by:
disconnect
in interfaceSession
- See Also:
-
dispatch
-
doStart
- Overrides:
doStart
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
dumpSelf
- Specified by:
dumpSelf
in interfaceorg.eclipse.jetty.util.component.Dumpable
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool() -
getClassLoader
-
getConnection
-
getContainerScope
Description copied from interface:WebSocketSessionScope
The parentWebSocketContainerScope
for this session scope.- Specified by:
getContainerScope
in interfaceWebSocketSessionScope
- Returns:
- the websocket container scope
-
getExtensionFactory
-
getIdleTimeout
public long getIdleTimeout()The idle timeout in milliseconds- Specified by:
getIdleTimeout
in interfaceSession
- Returns:
- the timeout in milliseconds.
-
getIncomingHandler
-
getLocalAddress
Description copied from interface:Session
Get the address of the local side.- Specified by:
getLocalAddress
in interfaceSession
- Returns:
- the local side address
-
getOutgoingHandler
-
getPolicy
Description copied from interface:Session
Access the (now read-only)WebSocketPolicy
in use for this connection. -
getProtocolVersion
Description copied from interface:Session
Returns 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:
getProtocolVersion
in interfaceSession
- Returns:
- the protocol version
-
getRemote
Description copied from interface:Session
Return a reference to the RemoteEndpoint object representing the other end of this conversation. -
getRemoteAddress
Description copied from interface:Session
Get the address of the remote side.- Specified by:
getRemoteAddress
in interfaceSession
- Returns:
- the remote side address
-
getRequestURI
-
getUpgradeRequest
Description copied from interface:Session
Get the UpgradeRequest used to create this session- Specified by:
getUpgradeRequest
in interfaceSession
- Returns:
- the UpgradeRequest used to create this session
-
getUpgradeResponse
Description copied from interface:Session
Get the UpgradeResponse used to create this session- Specified by:
getUpgradeResponse
in interfaceSession
- Returns:
- the UpgradeResponse used to create this session
-
getWebSocketSession
Description copied from interface:WebSocketSessionScope
ActiveWebSocketSession
associated with this scope.- Specified by:
getWebSocketSession
in interfaceWebSocketSessionScope
- Returns:
- the websocket session
-
incomingFrame
Incoming Raw Frames from Parser- Specified by:
incomingFrame
in interfaceIncomingFrames
- Parameters:
frame
- the frame to process
-
outgoingFrame
Description copied from interface:OutgoingFrames
A 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:
outgoingFrame
in 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
public boolean isOpen()Description copied from interface:Session
Return true if and only if the underlying socket is open. -
isSecure
public boolean isSecure()Description copied from interface:Session
Return true if and only if the underlying socket is using a secure transport. -
callApplicationOnClose
-
callApplicationOnError
-
onClosed
public void onClosed(org.eclipse.jetty.io.Connection connection) Jetty Connection onSessionClosed event- Specified by:
onClosed
in 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:
onOpened
in 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:
newRemoteEndpoint
in interfaceRemoteEndpointFactory
-
open
public void open()Open/Activate the session -
setExtensionFactory
-
setFuture
-
setIdleTimeout
public void setIdleTimeout(long ms) Set the timeout in milliseconds- Specified by:
setIdleTimeout
in interfaceSession
- Parameters:
ms
- the number of milliseconds.
-
setOutgoingHandler
-
setPolicy
Deprecated. -
setUpgradeRequest
-
setUpgradeResponse
-
suspend
Description copied from interface:Session
Suspend 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:
toString
in classorg.eclipse.jetty.util.component.AbstractLifeCycle
-