java.io.Closeable
, java.lang.AutoCloseable
, Connection
, Connection.UpgradeTo
, Dumpable
, OutgoingFrames
, SuspendToken
, IOState.ConnectionStateListener
, LogicalConnection
WebSocketClientConnection
, WebSocketServerConnection
public abstract class AbstractWebSocketConnection extends AbstractConnection implements LogicalConnection, Connection.UpgradeTo, IOState.ConnectionStateListener, Dumpable
LogicalConnection
within the framework of the new Connection
framework of jetty-io
.Modifier and Type | Class | Description |
---|---|---|
static class |
AbstractWebSocketConnection.Stats |
Connection.Listener, Connection.UpgradeFrom, Connection.UpgradeTo
Constructor | Description |
---|---|
AbstractWebSocketConnection(EndPoint endp,
java.util.concurrent.Executor executor,
Scheduler scheduler,
WebSocketPolicy policy,
ByteBufferPool bufferPool) |
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Jetty Connection Close
|
void |
disconnect() |
Terminate the connection (no close frame sent)
|
java.lang.String |
dump() |
|
void |
dump(java.lang.Appendable out,
java.lang.String indent) |
|
boolean |
equals(java.lang.Object obj) |
|
void |
fillInterested() |
Utility method to be called to register read interest.
|
ByteBufferPool |
getBufferPool() |
Get the ByteBufferPool in use by the connection
|
java.util.concurrent.Executor |
getExecutor() |
Get the Executor used by this connection.
|
java.util.List<ExtensionConfig> |
getExtensions() |
Get the list of extensions in use.
|
Generator |
getGenerator() |
|
java.lang.String |
getId() |
Get Unique ID for the Connection
|
long |
getIdleTimeout() |
Get the read/write idle timeout.
|
IOState |
getIOState() |
Get the IOState of the connection.
|
long |
getMaxIdleTimeout() |
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
|
Parser |
getParser() |
|
WebSocketPolicy |
getPolicy() |
The policy that the connection is running under.
|
java.net.InetSocketAddress |
getRemoteAddress() |
Get the remote Address in use for this connection.
|
Scheduler |
getScheduler() |
|
AbstractWebSocketConnection.Stats |
getStats() |
|
int |
hashCode() |
|
boolean |
isOpen() |
Test if logical connection is still open
|
boolean |
isReading() |
Tests if the connection is actively reading.
|
void |
onClose() |
Physical connection disconnect.
|
void |
onConnectionStateChange(ConnectionState state) |
|
void |
onFillable() |
Callback method invoked when the endpoint is ready to be read.
|
protected void |
onFillInterestedFailed(java.lang.Throwable cause) |
Callback method invoked when the endpoint failed to be ready to be read.
|
boolean |
onIdleExpired() |
Callback method invoked upon an idle timeout event.
|
void |
onLocalClose(CloseInfo close) |
Called to indicate a close frame was successfully sent to the remote.
|
void |
onOpen() |
Callback method invoked when this connection is opened.
|
protected boolean |
onReadTimeout(java.lang.Throwable timeout) |
Event for no activity on connection (read or write)
|
void |
onUpgradeTo(java.nio.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
|
void |
outgoingFrame(Frame frame,
WriteCallback callback,
BatchMode batchMode) |
Frame from API, User, or Internal implementation destined for network.
|
void |
resume() |
Resume a previously suspended connection.
|
void |
setExtensions(java.util.List<ExtensionConfig> extensions) |
Get the list of extensions in use.
|
protected void |
setInitialBuffer(java.nio.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
|
void |
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 |
setSession(WebSocketSession session) |
Associate the Active Session with the connection.
|
SuspendToken |
suspend() |
Suspend a the incoming read events on the connection.
|
java.lang.String |
toConnectionString() |
addListener, failedCallback, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getInputBufferSize, getMessagesIn, getMessagesOut, isFillInterested, removeListener, toString, tryFillInterested, tryFillInterested
getLocalAddress, setNextIncomingFrames
public AbstractWebSocketConnection(EndPoint endp, java.util.concurrent.Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
public java.util.concurrent.Executor getExecutor()
LogicalConnection
getExecutor
in interface LogicalConnection
getExecutor
in class AbstractConnection
public void onLocalClose(CloseInfo close)
LogicalConnection
onLocalClose
in interface LogicalConnection
close
- the close detailspublic void setSession(WebSocketSession session)
LogicalConnection
setSession
in interface LogicalConnection
session
- the session for this connectionpublic boolean onIdleExpired()
Connection
Callback method invoked upon an idle timeout event.
Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed.
When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event.
onIdleExpired
in interface Connection
onIdleExpired
in class AbstractConnection
public void close()
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in interface Connection
close
in class AbstractConnection
public void disconnect()
LogicalConnection
disconnect
in interface LogicalConnection
public void fillInterested()
AbstractConnection
Utility method to be called to register read interest.
After a call to this method, AbstractConnection.onFillable()
or AbstractConnection.onFillInterestedFailed(Throwable)
will be called back as appropriate.
fillInterested
in class AbstractConnection
AbstractConnection.onFillable()
public ByteBufferPool getBufferPool()
LogicalConnection
getBufferPool
in interface LogicalConnection
public java.util.List<ExtensionConfig> getExtensions()
This list is negotiated during the WebSocket Upgrade Request/Response handshake.
public Generator getGenerator()
public java.lang.String getId()
LogicalConnection
getId
in interface LogicalConnection
public long getIdleTimeout()
LogicalConnection
getIdleTimeout
in interface LogicalConnection
public IOState getIOState()
LogicalConnection
getIOState
in interface LogicalConnection
public long getMaxIdleTimeout()
LogicalConnection
getMaxIdleTimeout
in interface LogicalConnection
public Parser getParser()
public WebSocketPolicy getPolicy()
LogicalConnection
getPolicy
in interface LogicalConnection
public java.net.InetSocketAddress getRemoteAddress()
LogicalConnection
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.
getRemoteAddress
in interface LogicalConnection
public Scheduler getScheduler()
public AbstractWebSocketConnection.Stats getStats()
public boolean isOpen()
LogicalConnection
isOpen
in interface LogicalConnection
public boolean isReading()
LogicalConnection
isReading
in interface LogicalConnection
public void onClose()
Not related to WebSocket close handshake.
onClose
in interface Connection
onClose
in class AbstractConnection
public void onConnectionStateChange(ConnectionState state)
onConnectionStateChange
in interface IOState.ConnectionStateListener
public void onFillable()
AbstractConnection
Callback method invoked when the endpoint is ready to be read.
onFillable
in class AbstractConnection
AbstractConnection.fillInterested()
protected void onFillInterestedFailed(java.lang.Throwable cause)
AbstractConnection
Callback method invoked when the endpoint failed to be ready to be read.
onFillInterestedFailed
in class AbstractConnection
cause
- the exception that caused the failureprotected void setInitialBuffer(java.nio.ByteBuffer prefilled)
prefilled
- the bytes of prefilled content encountered during upgradepublic void onOpen()
Connection
Callback method invoked when this connection is opened.
Creators of the connection implementation are responsible for calling this method.
onOpen
in interface Connection
onOpen
in class AbstractConnection
protected boolean onReadTimeout(java.lang.Throwable timeout)
onReadTimeout
in class AbstractConnection
timeout
- the cause of the read timeoutpublic void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
outgoingFrame
in interface OutgoingFrames
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.public void resume()
SuspendToken
resume
in interface SuspendToken
public void setExtensions(java.util.List<ExtensionConfig> extensions)
This list is negotiated during the WebSocket Upgrade Request/Response handshake.
extensions
- the list of negotiated extensions in use.public void setInputBufferSize(int inputBufferSize)
setInputBufferSize
in class AbstractConnection
public void setMaxIdleTimeout(long ms)
LogicalConnection
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.
setMaxIdleTimeout
in interface LogicalConnection
ms
- the number of milliseconds of idle timeoutpublic SuspendToken suspend()
LogicalConnection
suspend
in interface LogicalConnection
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException
public java.lang.String toConnectionString()
toConnectionString
in class AbstractConnection
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void onUpgradeTo(java.nio.ByteBuffer prefilled)
onUpgradeTo
in interface Connection.UpgradeTo
prefilled
- An optional buffer that can contain prefilled data. Typically this
results from an upgrade of one protocol to the other where the old connection has buffered
data destined for the new connection. The new connection must take ownership of the buffer
and is responsible for returning it to the buffer poolCopyright © 1995–2018 Webtide. All rights reserved.