Class AbstractWebSocketConnection
- java.lang.Object
-
- org.eclipse.jetty.io.AbstractConnection
-
- org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection
-
- All Implemented Interfaces:
Closeable,AutoCloseable,org.eclipse.jetty.io.Connection,org.eclipse.jetty.io.Connection.UpgradeTo,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.websocket.api.extensions.OutgoingFrames,org.eclipse.jetty.websocket.api.SuspendToken,IOState.ConnectionStateListener,LogicalConnection
public abstract class AbstractWebSocketConnection extends org.eclipse.jetty.io.AbstractConnection implements LogicalConnection, org.eclipse.jetty.io.Connection.UpgradeTo, IOState.ConnectionStateListener, org.eclipse.jetty.util.component.Dumpable
Provides the implementation ofLogicalConnectionwithin the framework of the newConnectionframework ofjetty-io.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractWebSocketConnection.Stats
-
Constructor Summary
Constructors Constructor Description AbstractWebSocketConnection(org.eclipse.jetty.io.EndPoint endp, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Jetty Connection Closevoiddisconnect()Terminate the connection (no close frame sent)Stringdump()voiddump(Appendable out, String indent)booleanequals(Object obj)voidfillInterested()org.eclipse.jetty.io.ByteBufferPoolgetBufferPool()Get the ByteBufferPool in use by the connectionExecutorgetExecutor()Get the Executor used by this connection.List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig>getExtensions()Get the list of extensions in use.GeneratorgetGenerator()StringgetId()Get Unique ID for the ConnectionlonggetIdleTimeout()Get the read/write idle timeout.IOStategetIOState()Get the IOState of the connection.longgetMaxIdleTimeout()Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)ParsergetParser()org.eclipse.jetty.websocket.api.WebSocketPolicygetPolicy()The policy that the connection is running under.InetSocketAddressgetRemoteAddress()Get the remote Address in use for this connection.org.eclipse.jetty.util.thread.SchedulergetScheduler()AbstractWebSocketConnection.StatsgetStats()inthashCode()booleanisOpen()Test if logical connection is still openbooleanisReading()Tests if the connection is actively reading.voidonClose()Physical connection disconnect.voidonConnectionStateChange(ConnectionState state)voidonFillable()protected voidonFillInterestedFailed(Throwable cause)booleanonIdleExpired()voidonLocalClose(CloseInfo close)Called to indicate a close frame was successfully sent to the remote.voidonOpen()protected booleanonReadTimeout(Throwable timeout)Event for no activity on connection (read or write)voidonUpgradeTo(ByteBuffer prefilled)Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionvoidoutgoingFrame(org.eclipse.jetty.websocket.api.extensions.Frame frame, org.eclipse.jetty.websocket.api.WriteCallback callback, org.eclipse.jetty.websocket.api.BatchMode batchMode)Frame from API, User, or Internal implementation destined for network.voidresume()voidsetExtensions(List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> extensions)Get the list of extensions in use.protected voidsetInitialBuffer(ByteBuffer prefilled)Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionvoidsetInputBufferSize(int inputBufferSize)voidsetMaxIdleTimeout(long ms)Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)voidsetSession(WebSocketSession session)Associate the Active Session with the connection.org.eclipse.jetty.websocket.api.SuspendTokensuspend()Suspend a the incoming read events on the connection.StringtoConnectionString()-
Methods inherited from class org.eclipse.jetty.io.AbstractConnection
addListener, failedCallback, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getInputBufferSize, getMessagesIn, getMessagesOut, isFillInterested, removeListener, toString, tryFillInterested, tryFillInterested
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.websocket.common.LogicalConnection
getLocalAddress, setNextIncomingFrames
-
-
-
-
Constructor Detail
-
AbstractWebSocketConnection
public AbstractWebSocketConnection(org.eclipse.jetty.io.EndPoint endp, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.websocket.api.WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool)
-
-
Method Detail
-
getExecutor
public Executor getExecutor()
Description copied from interface:LogicalConnectionGet the Executor used by this connection.- Specified by:
getExecutorin interfaceLogicalConnection- Overrides:
getExecutorin classorg.eclipse.jetty.io.AbstractConnection- Returns:
- the executor
-
onLocalClose
public void onLocalClose(CloseInfo close)
Description copied from interface:LogicalConnectionCalled to indicate a close frame was successfully sent to the remote.- Specified by:
onLocalClosein interfaceLogicalConnection- Parameters:
close- the close details
-
setSession
public void setSession(WebSocketSession session)
Description copied from interface:LogicalConnectionAssociate the Active Session with the connection.- Specified by:
setSessionin interfaceLogicalConnection- Parameters:
session- the session for this connection
-
onIdleExpired
public boolean onIdleExpired()
- Specified by:
onIdleExpiredin interfaceorg.eclipse.jetty.io.Connection- Overrides:
onIdleExpiredin classorg.eclipse.jetty.io.AbstractConnection
-
close
public void close()
Jetty Connection Close- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceorg.eclipse.jetty.io.Connection- Overrides:
closein classorg.eclipse.jetty.io.AbstractConnection
-
disconnect
public void disconnect()
Description copied from interface:LogicalConnectionTerminate the connection (no close frame sent)- Specified by:
disconnectin interfaceLogicalConnection
-
fillInterested
public void fillInterested()
- Overrides:
fillInterestedin classorg.eclipse.jetty.io.AbstractConnection
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool()
Description copied from interface:LogicalConnectionGet the ByteBufferPool in use by the connection- Specified by:
getBufferPoolin interfaceLogicalConnection- Returns:
- the buffer pool
-
getExtensions
public List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> 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
public Generator getGenerator()
-
getId
public String getId()
Description copied from interface:LogicalConnectionGet Unique ID for the Connection- Specified by:
getIdin interfaceLogicalConnection- Returns:
- the unique ID for the connection
-
getIdleTimeout
public long getIdleTimeout()
Description copied from interface:LogicalConnectionGet the read/write idle timeout.- Specified by:
getIdleTimeoutin interfaceLogicalConnection- Returns:
- the idle timeout in milliseconds
-
getIOState
public IOState getIOState()
Description copied from interface:LogicalConnectionGet the IOState of the connection.- Specified by:
getIOStatein interfaceLogicalConnection- Returns:
- the IOState of the connection.
-
getMaxIdleTimeout
public long getMaxIdleTimeout()
Description copied from interface:LogicalConnectionSet the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)- Specified by:
getMaxIdleTimeoutin interfaceLogicalConnection- Returns:
- the idle timeout in milliseconds
-
getParser
public Parser getParser()
-
getPolicy
public org.eclipse.jetty.websocket.api.WebSocketPolicy getPolicy()
Description copied from interface:LogicalConnectionThe policy that the connection is running under.- Specified by:
getPolicyin interfaceLogicalConnection- Returns:
- the policy for the connection
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:LogicalConnectionGet 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:
getRemoteAddressin interfaceLogicalConnection- Returns:
- the remote address.
-
getScheduler
public org.eclipse.jetty.util.thread.Scheduler getScheduler()
-
getStats
public AbstractWebSocketConnection.Stats getStats()
-
isOpen
public boolean isOpen()
Description copied from interface:LogicalConnectionTest if logical connection is still open- Specified by:
isOpenin interfaceLogicalConnection- Returns:
- true if connection is open
-
isReading
public boolean isReading()
Description copied from interface:LogicalConnectionTests if the connection is actively reading.- Specified by:
isReadingin interfaceLogicalConnection- Returns:
- true if connection is actively attempting to read.
-
onClose
public void onClose()
Physical connection disconnect.Not related to WebSocket close handshake.
- Specified by:
onClosein interfaceorg.eclipse.jetty.io.Connection- Overrides:
onClosein classorg.eclipse.jetty.io.AbstractConnection
-
onConnectionStateChange
public void onConnectionStateChange(ConnectionState state)
- Specified by:
onConnectionStateChangein interfaceIOState.ConnectionStateListener
-
onFillable
public void onFillable()
- Specified by:
onFillablein classorg.eclipse.jetty.io.AbstractConnection
-
onFillInterestedFailed
protected void onFillInterestedFailed(Throwable cause)
- Overrides:
onFillInterestedFailedin classorg.eclipse.jetty.io.AbstractConnection
-
setInitialBuffer
protected void setInitialBuffer(ByteBuffer prefilled)
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:
prefilled- the bytes of prefilled content encountered during upgrade
-
onOpen
public void onOpen()
- Specified by:
onOpenin interfaceorg.eclipse.jetty.io.Connection- Overrides:
onOpenin classorg.eclipse.jetty.io.AbstractConnection
-
onReadTimeout
protected boolean onReadTimeout(Throwable timeout)
Event for no activity on connection (read or write)- Overrides:
onReadTimeoutin classorg.eclipse.jetty.io.AbstractConnection- Returns:
- true to signal that the endpoint must be closed, false to keep the endpoint open
-
outgoingFrame
public void outgoingFrame(org.eclipse.jetty.websocket.api.extensions.Frame frame, org.eclipse.jetty.websocket.api.WriteCallback callback, org.eclipse.jetty.websocket.api.BatchMode batchMode)Frame from API, User, or Internal implementation destined for network.- Specified by:
outgoingFramein interfaceorg.eclipse.jetty.websocket.api.extensions.OutgoingFrames
-
resume
public void resume()
- Specified by:
resumein interfaceorg.eclipse.jetty.websocket.api.SuspendToken
-
setExtensions
public void setExtensions(List<org.eclipse.jetty.websocket.api.extensions.ExtensionConfig> extensions)
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:
setInputBufferSizein classorg.eclipse.jetty.io.AbstractConnection
-
setMaxIdleTimeout
public void setMaxIdleTimeout(long ms)
Description copied from interface:LogicalConnectionSet 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:
setMaxIdleTimeoutin interfaceLogicalConnection- Parameters:
ms- the number of milliseconds of idle timeout
-
suspend
public org.eclipse.jetty.websocket.api.SuspendToken suspend()
Description copied from interface:LogicalConnectionSuspend a the incoming read events on the connection.- Specified by:
suspendin interfaceLogicalConnection- Returns:
- the suspend token
-
dump
public String dump()
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(Appendable out, String indent) throws IOException
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
toConnectionString
public String toConnectionString()
- Overrides:
toConnectionStringin classorg.eclipse.jetty.io.AbstractConnection
-
onUpgradeTo
public void onUpgradeTo(ByteBuffer prefilled)
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:
onUpgradeToin interfaceorg.eclipse.jetty.io.Connection.UpgradeTo
-
-