Class AbstractWebSocketConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.eclipse.jetty.io.Connection
,org.eclipse.jetty.io.Connection.UpgradeTo
,org.eclipse.jetty.util.component.Dumpable
,OutgoingFrames
,SuspendToken
,LogicalConnection
- Direct Known Subclasses:
WebSocketClientConnection
,WebSocketServerConnection
LogicalConnection
within the framework of the new Connection
framework of jetty-io
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private class
static class
Deprecated.Nested classes/interfaces inherited from interface org.eclipse.jetty.io.Connection
org.eclipse.jetty.io.Connection.Listener, org.eclipse.jetty.io.Connection.UpgradeFrom, org.eclipse.jetty.io.Connection.UpgradeTo
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.eclipse.jetty.io.ByteBufferPool
private final LongAdder
private final ConnectionState
private List
<ExtensionConfig> private CloseInfo
private final FrameFlusher
private final Generator
private final String
private static final AtomicLong
private ByteBuffer
private static final org.eclipse.jetty.util.log.Logger
private static final int
Minimum size of a buffer is the determined to be what would be the maximum framing header size (not including payload)private final Parser
private final WebSocketPolicy
private final ReadState
private final org.eclipse.jetty.util.thread.Scheduler
private WebSocketSession
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractWebSocketConnection
(org.eclipse.jetty.io.EndPoint endp, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Test if Connection State allows for reading of frames.boolean
Test if Connection State allows for writing frames.void
close()
Jetty Connection Closevoid
Close the connection based on the throwablevoid
Request a local close.void
Terminate the connection (no close frame sent)void
dump
(Appendable out, String indent) dumpSelf()
void
org.eclipse.jetty.io.ByteBufferPool
Get the ByteBufferPool in use by the connectionlong
long
Get the Executor used by this connection.Get the list of extensions in use.getId()
Get Unique ID for the Connectionlong
Get the read/write idle timeout.Get the localInetSocketAddress
in use for this connection.long
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)long
long
The policy that the connection is running under.Get the remote Address in use for this connection.org.eclipse.jetty.util.thread.Scheduler
getStats()
Deprecated.boolean
isOpen()
Test if logical connection is still openboolean
Tests if the connection is actively reading.void
private void
onFillable
(ByteBuffer buffer) protected void
onFillInterestedFailed
(Throwable cause) boolean
protected boolean
onReadTimeout
(Throwable timeout) Event for no activity on connection (read or write)void
onUpgradeTo
(ByteBuffer buffer) Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionboolean
opened()
Set the state to opened (the application onOpen() method has been called successfully).boolean
opening()
Set the state to upgrade/opening handshake has completed.void
outgoingFrame
(Frame frame, WriteCallback callback, BatchMode batchMode) Frame from API, User, or Internal implementation destined for network.void
remoteClose
(CloseInfo close) Report that the Remote Endpoint CLOSE Frame has been receivedvoid
resume()
Resume a previously suspended connection.void
setExtensions
(List<ExtensionConfig> extensions) Get the list of extensions in use.protected void
setInitialBuffer
(ByteBuffer initialBuffer) Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionvoid
setInputBufferSize
(int inputBufferSize) void
setMaxIdleTimeout
(long ms) Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)void
setNextIncomingFrames
(IncomingFrames incoming) Set where the connection should send the incoming frames to.void
setSession
(WebSocketSession session) Associate the Active Session with the connection.suspend()
Suspend a the incoming read events on the connection.Get the Connection State as a StringMethods inherited from class org.eclipse.jetty.io.AbstractConnection
addListener, failedCallback, getCreatedTimeStamp, getEndPoint, getInputBufferSize, isFillInterested, onClose, onOpen, removeListener, toString, tryFillInterested, tryFillInterested
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
dump
-
Field Details
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
ID_GEN
-
MIN_BUFFER_SIZE
private static final int MIN_BUFFER_SIZEMinimum size of a buffer is the determined to be what would be the maximum framing header size (not including payload)- See Also:
-
bufferPool
private final org.eclipse.jetty.io.ByteBufferPool bufferPool -
scheduler
private final org.eclipse.jetty.util.thread.Scheduler scheduler -
generator
-
parser
-
policy
-
readState
-
connectionState
-
flusher
-
id
-
bytesIn
-
session
-
extensions
-
initialBuffer
-
stats
-
fatalCloseInfo
-
-
Constructor Details
-
AbstractWebSocketConnection
public AbstractWebSocketConnection(org.eclipse.jetty.io.EndPoint endp, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool)
-
-
Method Details
-
getExecutor
Description copied from interface:LogicalConnection
Get the Executor used by this connection.- Specified by:
getExecutor
in interfaceLogicalConnection
- Overrides:
getExecutor
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- the executor
-
close
Description copied from interface:LogicalConnection
Request a local close.- Specified by:
close
in interfaceLogicalConnection
-
close
Close the connection based on the throwable- Specified by:
close
in interfaceLogicalConnection
- Parameters:
cause
- the cause
-
canWriteWebSocketFrames
public boolean canWriteWebSocketFrames()Description copied from interface:LogicalConnection
Test if Connection State allows for writing frames.- Specified by:
canWriteWebSocketFrames
in interfaceLogicalConnection
- Returns:
- true if able to write, false otherwise.
-
canReadWebSocketFrames
public boolean canReadWebSocketFrames()Description copied from interface:LogicalConnection
Test if Connection State allows for reading of frames.- Specified by:
canReadWebSocketFrames
in interfaceLogicalConnection
- Returns:
- true if able to read, false otherwise.
-
toStateString
Description copied from interface:LogicalConnection
Get the Connection State as a String- Specified by:
toStateString
in interfaceLogicalConnection
- Returns:
- the Connection State string
-
opening
public boolean opening()Description copied from interface:LogicalConnection
Set the state to upgrade/opening handshake has completed.- Specified by:
opening
in interfaceLogicalConnection
- Returns:
- true if state is OPENING, false otherwise
-
opened
public boolean opened()Description copied from interface:LogicalConnection
Set the state to opened (the application onOpen() method has been called successfully).Reads from network begin here.
- Specified by:
opened
in interfaceLogicalConnection
- Returns:
- true if state is OPENED, false otherwise
-
remoteClose
Description copied from interface:LogicalConnection
Report that the Remote Endpoint CLOSE Frame has been received- Specified by:
remoteClose
in interfaceLogicalConnection
- Parameters:
close
- the close frame details
-
setSession
Description copied from interface:LogicalConnection
Associate the Active Session with the connection.- Specified by:
setSession
in interfaceLogicalConnection
- Parameters:
session
- the session for this connection
-
onIdleExpired
public boolean onIdleExpired()- Specified by:
onIdleExpired
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
onIdleExpired
in classorg.eclipse.jetty.io.AbstractConnection
-
close
public void close()Jetty Connection Close- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
close
in classorg.eclipse.jetty.io.AbstractConnection
-
disconnect
public void disconnect()Description copied from interface:LogicalConnection
Terminate the connection (no close frame sent)- Specified by:
disconnect
in interfaceLogicalConnection
-
fillInterested
public void fillInterested()- Overrides:
fillInterested
in classorg.eclipse.jetty.io.AbstractConnection
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool()Description copied from interface:LogicalConnection
Get the ByteBufferPool in use by the connection- Specified by:
getBufferPool
in interfaceLogicalConnection
- Returns:
- the buffer pool
-
getExtensions
Get the list of extensions in use.This list is negotiated during the WebSocket Upgrade Request/Response handshake.
- Returns:
- the list of negotiated extensions in use.
-
getGenerator
-
getId
Description copied from interface:LogicalConnection
Get Unique ID for the Connection- Specified by:
getId
in interfaceLogicalConnection
- Returns:
- the unique ID for the connection
-
getIdleTimeout
public long getIdleTimeout()Description copied from interface:LogicalConnection
Get the read/write idle timeout.- Specified by:
getIdleTimeout
in interfaceLogicalConnection
- Returns:
- the idle timeout in milliseconds
-
getMaxIdleTimeout
public long getMaxIdleTimeout()Description copied from interface:LogicalConnection
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)- Specified by:
getMaxIdleTimeout
in interfaceLogicalConnection
- Returns:
- the idle timeout in milliseconds
-
getParser
-
getPolicy
Description copied from interface:LogicalConnection
The policy that the connection is running under.- Specified by:
getPolicy
in interfaceLogicalConnection
- Returns:
- the policy for the connection
-
getLocalAddress
Description copied from interface:LogicalConnection
Get the localInetSocketAddress
in use for this connection.Note: Non-physical connections, like during the Mux extensions, or during unit testing can result in a InetSocketAddress on port 0 and/or on localhost.
- Specified by:
getLocalAddress
in interfaceLogicalConnection
- Returns:
- the local address.
-
getRemoteAddress
Description copied from interface:LogicalConnection
Get the remote Address in use for this connection.Note: Non-physical connections, like during the Mux extensions, or during unit testing can result in a InetSocketAddress on port 0 and/or on localhost.
- Specified by:
getRemoteAddress
in interfaceLogicalConnection
- Returns:
- the remote address.
-
getScheduler
public org.eclipse.jetty.util.thread.Scheduler getScheduler() -
getStats
Deprecated. -
isOpen
public boolean isOpen()Description copied from interface:LogicalConnection
Test if logical connection is still open- Specified by:
isOpen
in interfaceLogicalConnection
- Returns:
- true if connection is open
-
isReading
public boolean isReading()Description copied from interface:LogicalConnection
Tests if the connection is actively reading.- Specified by:
isReading
in interfaceLogicalConnection
- Returns:
- true if connection is actively attempting to read.
-
onFillable
public void onFillable()- Specified by:
onFillable
in classorg.eclipse.jetty.io.AbstractConnection
-
onFillable
-
resume
public void resume()Description copied from interface:SuspendToken
Resume a previously suspended connection.- Specified by:
resume
in interfaceSuspendToken
-
suspend
Description copied from interface:LogicalConnection
Suspend a the incoming read events on the connection.- Specified by:
suspend
in interfaceLogicalConnection
- Returns:
- the suspend token
-
onFillInterestedFailed
- Overrides:
onFillInterestedFailed
in classorg.eclipse.jetty.io.AbstractConnection
-
setInitialBuffer
Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection- Parameters:
initialBuffer
- the bytes of unconsumed content encountered during upgrade
-
onReadTimeout
Event for no activity on connection (read or write)- Overrides:
onReadTimeout
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- true to signal that the endpoint must be closed, false to keep the endpoint open
-
outgoingFrame
Frame from API, User, or Internal implementation destined for network.- 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.
-
setExtensions
Get the list of extensions in use.This list is negotiated during the WebSocket Upgrade Request/Response handshake.
- Parameters:
extensions
- the list of negotiated extensions in use.
-
setInputBufferSize
public void setInputBufferSize(int inputBufferSize) - Overrides:
setInputBufferSize
in classorg.eclipse.jetty.io.AbstractConnection
-
setMaxIdleTimeout
public void setMaxIdleTimeout(long ms) Description copied from interface:LogicalConnection
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)This idle timeout cannot be garunteed to take immediate effect for any active read/write actions. New read/write actions will have this new idle timeout.
- Specified by:
setMaxIdleTimeout
in interfaceLogicalConnection
- Parameters:
ms
- the number of milliseconds of idle timeout
-
dumpSelf
- Specified by:
dumpSelf
in interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
- Specified by:
dump
in interfaceorg.eclipse.jetty.util.component.Dumpable
- Throws:
IOException
-
toConnectionString
- Overrides:
toConnectionString
in classorg.eclipse.jetty.io.AbstractConnection
-
onUpgradeTo
Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection- Specified by:
onUpgradeTo
in interfaceorg.eclipse.jetty.io.Connection.UpgradeTo
-
setNextIncomingFrames
Description copied from interface:LogicalConnection
Set where the connection should send the incoming frames to.Often this is from the Parser to the start of the extension stack, and eventually on to the session.
- Specified by:
setNextIncomingFrames
in interfaceLogicalConnection
- Parameters:
incoming
- the incoming frames handler
-
getMessagesIn
public long getMessagesIn()- Specified by:
getMessagesIn
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getMessagesIn
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- the number of WebSocket frames received over this connection
-
getMessagesOut
public long getMessagesOut()- Specified by:
getMessagesOut
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getMessagesOut
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- the number of WebSocket frames sent over this connection
-
getBytesIn
public long getBytesIn()- Specified by:
getBytesIn
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getBytesIn
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- the number of bytes received over this connection
-
getBytesOut
public long getBytesOut()- Specified by:
getBytesOut
in interfaceorg.eclipse.jetty.io.Connection
- Overrides:
getBytesOut
in classorg.eclipse.jetty.io.AbstractConnection
- Returns:
- the number of bytes frames sent over this connection
-